Skip to content

Commit 67bbe1f

Browse files
committed
Major 2.0.0 update:
- code refactoring - much more information
1 parent 767e4c1 commit 67bbe1f

25 files changed

+554
-157
lines changed

PLP-SystemInfo.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.4.33213.308
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PLP-SystemInfo", "PLP-SystemInfo\PLP-SystemInfo.csproj", "{193C7457-B4BA-4120-9400-5F501F6573A0}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PLP-SystemInfo", "PLP-SystemInfo\PLP-SystemInfo.csproj", "{193C7457-B4BA-4120-9400-5F501F6573A0}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PLP_SystemInfoTest", "PLP_SystemInfoTest\PLP_SystemInfoTest.csproj", "{67F6C47C-DFE3-45D9-9537-FE8433451496}"
79
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
1517
{193C7457-B4BA-4120-9400-5F501F6573A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{193C7457-B4BA-4120-9400-5F501F6573A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{193C7457-B4BA-4120-9400-5F501F6573A0}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using PLP_SystemInfo.Models;
2+
using System.Collections.ObjectModel;
3+
4+
namespace PLP_SystemInfo.Collections
5+
{
6+
public class GraphicsCollection : Collection<GraphicsCard>
7+
{
8+
public override string ToString()
9+
{
10+
return base.ToString() + " : " + this.Count + " items";
11+
}
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using PLP_SystemInfo.Models;
2+
using System.Collections.ObjectModel;
3+
4+
namespace PLP_SystemInfo.Collections
5+
{
6+
public class ProcessorCollection : Collection<Processor>
7+
{
8+
public override string ToString()
9+
{
10+
return base.ToString() + " : " + this.Count + " items";
11+
}
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using PLP_SystemInfo.Models;
2+
using System.Collections.ObjectModel;
3+
4+
namespace PLP_SystemInfo.Collections
5+
{
6+
public class RamCollection : Collection<RAM>
7+
{
8+
public override string ToString()
9+
{
10+
return base.ToString() + " : " + this.Count + " items";
11+
}
12+
}
13+
}

PLP-SystemInfo/ComponentInfo.cs

Lines changed: 0 additions & 151 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using PLP_SystemInfo.Models;
2+
using System.Management;
3+
4+
namespace PLP_SystemInfo.ComponentInfo
5+
{
6+
public class BoardInfo
7+
{
8+
//Motherboard
9+
public static Board GetMotherboard()
10+
{
11+
string manufacturer = "";
12+
string model = "";
13+
14+
ManagementClass mgc = new ManagementClass("Win32_BaseBoard");
15+
foreach (ManagementObject o in mgc.GetInstances())
16+
{
17+
manufacturer = o["Manufacturer"].ToString();
18+
model = o["Product"].ToString();
19+
}
20+
21+
return new Board(manufacturer, model);
22+
}
23+
24+
public static BIOS GetBIOSInfo()
25+
{
26+
string manufacturer = "";
27+
string versionName = "";
28+
string version = "";
29+
30+
ManagementClass mc = new ManagementClass("Win32_BIOS");
31+
foreach (ManagementObject o in mc.GetInstances())
32+
{
33+
versionName = o["Name"].ToString();
34+
version = o["SystemBiosMajorVersion"].ToString() + "." + o["SystemBiosMinorVersion"].ToString();
35+
manufacturer = o["Manufacturer"].ToString();
36+
}
37+
38+
return new BIOS(manufacturer, versionName, version);
39+
}
40+
}
41+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using PLP_SystemInfo.Collections;
2+
using System;
3+
using System.Management;
4+
5+
namespace PLP_SystemInfo.ComponentInfo
6+
{
7+
public class GraphicsInfo
8+
{
9+
//Graphics
10+
public static GraphicsCollection GetGraphicscardInfo()
11+
{
12+
GraphicsCollection graphics = new GraphicsCollection();
13+
14+
try
15+
{
16+
ManagementClass c = new ManagementClass("Win32_VideoController");
17+
foreach (ManagementObject o in c.GetInstances())
18+
{
19+
graphics.Add(new Models.GraphicsCard(o["Name"].ToString(), o["DriverVersion"].ToString()));
20+
}
21+
22+
}
23+
catch (Exception e)
24+
{
25+
Console.WriteLine("An error occurred while querying for WMI data: " + e.Message);
26+
}
27+
28+
return graphics;
29+
}
30+
}
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Management;
2+
3+
namespace PLP_SystemInfo.ComponentInfo
4+
{
5+
public class OSInfo
6+
{
7+
public static string GetOperatingSystemInfo()
8+
{
9+
string osa = "";
10+
string osv = "";
11+
12+
ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_OperatingSystem");
13+
foreach (ManagementObject managementObject in mos.Get())
14+
{
15+
if (managementObject["Caption"] != null)
16+
{
17+
osv = managementObject["Caption"].ToString();
18+
}
19+
if (managementObject["OSArchitecture"] != null)
20+
{
21+
osa = managementObject["OSArchitecture"].ToString();
22+
}
23+
}
24+
25+
return $"{osv} ({osa})";
26+
}
27+
}
28+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using PLP_SystemInfo.Collections;
2+
using System;
3+
using System.Collections.ObjectModel;
4+
using System.Management;
5+
6+
namespace PLP_SystemInfo.ComponentInfo
7+
{
8+
public class ProcessorInfo
9+
{
10+
//Processor
11+
static string GetProcessorArchitecture(int i)
12+
{
13+
switch (i)
14+
{
15+
case 0:
16+
return "x86";
17+
case 1:
18+
return "MIPS";
19+
case 2:
20+
return "Alpha";
21+
case 3:
22+
return "PowerPC";
23+
case 5:
24+
return "ARM";
25+
case 6:
26+
return "ia64";
27+
case 9:
28+
return "x64";
29+
case 12:
30+
return "ARM64";
31+
default: return "unknown";
32+
}
33+
}
34+
35+
static Collection<double> GetCacheSize()
36+
{
37+
Collection<double> result = new Collection<double>();
38+
39+
ManagementClass mgmtc = new ManagementClass("Win32_CacheMemory");
40+
foreach (ManagementObject o in mgmtc.GetInstances())
41+
{
42+
double max = double.Parse(o["MaxCacheSize"].ToString()) / 1024d;
43+
result.Add(max);
44+
}
45+
46+
return result;
47+
}
48+
49+
public static ProcessorCollection GetProcessors()
50+
{
51+
ProcessorCollection processors = new ProcessorCollection();
52+
Collection<double> result = GetCacheSize();
53+
54+
int i = -1;
55+
foreach (var item in new ManagementObjectSearcher("Select * from Win32_Processor").Get())
56+
{
57+
i++;
58+
processors.Add(new Models.Processor(
59+
item["Name"].ToString(),
60+
GetProcessorArchitecture(int.Parse(item["Architecture"].ToString())),
61+
Environment.ProcessorCount,
62+
int.Parse(item["NumberOfCores"].ToString()),
63+
double.Parse(item["L2CacheSize"].ToString()) / 1024d,
64+
double.Parse(item["L3CacheSize"].ToString()) / 1024d,
65+
result[i],
66+
double.Parse(item["CurrentClockSpeed"].ToString()) / 1000d,
67+
double.Parse(item["MaxClockSpeed"].ToString()) / 1000d));
68+
}
69+
70+
return processors;
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)