-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessorConfig.cs
51 lines (42 loc) · 1.69 KB
/
ProcessorConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Management;
namespace powerLabel
{
public class ProcessorConfig
{
public int id { get; set; }
public Processor processor { get; set; }
public int amount { get; set; }
public ComputerSystem computerSystem { get; set; }
public static ProcessorConfig GetProcessors(ComputerSystem system)
{
ProcessorConfig processorConfig = new ProcessorConfig();
ManagementObjectCollection returned = PSInterface.RunObjectQuery("SELECT * FROM Win32_Processor");
ManagementObject item = null;
foreach (ManagementObject obj in returned)
{
item = obj;
break;
}
processorConfig.amount = (returned.Count > 1) ? 2 : 1;
processorConfig.processor = new Processor();
processorConfig.processor.name = (string)item["Name"];
processorConfig.processor.cores = (uint)item["NumberOfCores"];
processorConfig.processor.threads = (uint)item["NumberOfLogicalProcessors"];
processorConfig.computerSystem = system;
return processorConfig;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType()) return false;
ProcessorConfig processorConfig = (ProcessorConfig)obj;
if (this.processor.Equals(processorConfig.processor) &&
this.amount == processorConfig.amount &&
this.computerSystem.motherboard.Equals(processorConfig.computerSystem.motherboard)
)
{
return true;
}
return false;
}
}
}