-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- code refactoring - much more information
- Loading branch information
1 parent
767e4c1
commit 67bbe1f
Showing
25 changed files
with
554 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using PLP_SystemInfo.Models; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace PLP_SystemInfo.Collections | ||
{ | ||
public class GraphicsCollection : Collection<GraphicsCard> | ||
{ | ||
public override string ToString() | ||
{ | ||
return base.ToString() + " : " + this.Count + " items"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using PLP_SystemInfo.Models; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace PLP_SystemInfo.Collections | ||
{ | ||
public class ProcessorCollection : Collection<Processor> | ||
{ | ||
public override string ToString() | ||
{ | ||
return base.ToString() + " : " + this.Count + " items"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using PLP_SystemInfo.Models; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace PLP_SystemInfo.Collections | ||
{ | ||
public class RamCollection : Collection<RAM> | ||
{ | ||
public override string ToString() | ||
{ | ||
return base.ToString() + " : " + this.Count + " items"; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using PLP_SystemInfo.Models; | ||
using System.Management; | ||
|
||
namespace PLP_SystemInfo.ComponentInfo | ||
{ | ||
public class BoardInfo | ||
{ | ||
//Motherboard | ||
public static Board GetMotherboard() | ||
{ | ||
string manufacturer = ""; | ||
string model = ""; | ||
|
||
ManagementClass mgc = new ManagementClass("Win32_BaseBoard"); | ||
foreach (ManagementObject o in mgc.GetInstances()) | ||
{ | ||
manufacturer = o["Manufacturer"].ToString(); | ||
model = o["Product"].ToString(); | ||
} | ||
|
||
return new Board(manufacturer, model); | ||
} | ||
|
||
public static BIOS GetBIOSInfo() | ||
{ | ||
string manufacturer = ""; | ||
string versionName = ""; | ||
string version = ""; | ||
|
||
ManagementClass mc = new ManagementClass("Win32_BIOS"); | ||
foreach (ManagementObject o in mc.GetInstances()) | ||
{ | ||
versionName = o["Name"].ToString(); | ||
version = o["SystemBiosMajorVersion"].ToString() + "." + o["SystemBiosMinorVersion"].ToString(); | ||
manufacturer = o["Manufacturer"].ToString(); | ||
} | ||
|
||
return new BIOS(manufacturer, versionName, version); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using PLP_SystemInfo.Collections; | ||
using System; | ||
using System.Management; | ||
|
||
namespace PLP_SystemInfo.ComponentInfo | ||
{ | ||
public class GraphicsInfo | ||
{ | ||
//Graphics | ||
public static GraphicsCollection GetGraphicscardInfo() | ||
{ | ||
GraphicsCollection graphics = new GraphicsCollection(); | ||
|
||
try | ||
{ | ||
ManagementClass c = new ManagementClass("Win32_VideoController"); | ||
foreach (ManagementObject o in c.GetInstances()) | ||
{ | ||
graphics.Add(new Models.GraphicsCard(o["Name"].ToString(), o["DriverVersion"].ToString())); | ||
} | ||
|
||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine("An error occurred while querying for WMI data: " + e.Message); | ||
} | ||
|
||
return graphics; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Management; | ||
|
||
namespace PLP_SystemInfo.ComponentInfo | ||
{ | ||
public class OSInfo | ||
{ | ||
public static string GetOperatingSystemInfo() | ||
{ | ||
string osa = ""; | ||
string osv = ""; | ||
|
||
ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_OperatingSystem"); | ||
foreach (ManagementObject managementObject in mos.Get()) | ||
{ | ||
if (managementObject["Caption"] != null) | ||
{ | ||
osv = managementObject["Caption"].ToString(); | ||
} | ||
if (managementObject["OSArchitecture"] != null) | ||
{ | ||
osa = managementObject["OSArchitecture"].ToString(); | ||
} | ||
} | ||
|
||
return $"{osv} ({osa})"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using PLP_SystemInfo.Collections; | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Management; | ||
|
||
namespace PLP_SystemInfo.ComponentInfo | ||
{ | ||
public class ProcessorInfo | ||
{ | ||
//Processor | ||
static string GetProcessorArchitecture(int i) | ||
{ | ||
switch (i) | ||
{ | ||
case 0: | ||
return "x86"; | ||
case 1: | ||
return "MIPS"; | ||
case 2: | ||
return "Alpha"; | ||
case 3: | ||
return "PowerPC"; | ||
case 5: | ||
return "ARM"; | ||
case 6: | ||
return "ia64"; | ||
case 9: | ||
return "x64"; | ||
case 12: | ||
return "ARM64"; | ||
default: return "unknown"; | ||
} | ||
} | ||
|
||
static Collection<double> GetCacheSize() | ||
{ | ||
Collection<double> result = new Collection<double>(); | ||
|
||
ManagementClass mgmtc = new ManagementClass("Win32_CacheMemory"); | ||
foreach (ManagementObject o in mgmtc.GetInstances()) | ||
{ | ||
double max = double.Parse(o["MaxCacheSize"].ToString()) / 1024d; | ||
result.Add(max); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static ProcessorCollection GetProcessors() | ||
{ | ||
ProcessorCollection processors = new ProcessorCollection(); | ||
Collection<double> result = GetCacheSize(); | ||
|
||
int i = -1; | ||
foreach (var item in new ManagementObjectSearcher("Select * from Win32_Processor").Get()) | ||
{ | ||
i++; | ||
processors.Add(new Models.Processor( | ||
item["Name"].ToString(), | ||
GetProcessorArchitecture(int.Parse(item["Architecture"].ToString())), | ||
Environment.ProcessorCount, | ||
int.Parse(item["NumberOfCores"].ToString()), | ||
double.Parse(item["L2CacheSize"].ToString()) / 1024d, | ||
double.Parse(item["L3CacheSize"].ToString()) / 1024d, | ||
result[i], | ||
double.Parse(item["CurrentClockSpeed"].ToString()) / 1000d, | ||
double.Parse(item["MaxClockSpeed"].ToString()) / 1000d)); | ||
} | ||
|
||
return processors; | ||
} | ||
} | ||
} |
Oops, something went wrong.