SubHardware in the sample code (#332)
* SubHardware in the sample code Some of the people who run the sample code may not understand why they cannot see the information from the motherboard. It's a good idea to show the subhardware sensors right away.
This commit is contained in:
@@ -63,7 +63,7 @@ public void Monitor()
|
||||
IsControllerEnabled = true,
|
||||
IsNetworkEnabled = true,
|
||||
IsStorageEnabled = true
|
||||
};
|
||||
};
|
||||
|
||||
computer.Open();
|
||||
computer.Accept(new UpdateVisitor());
|
||||
@@ -71,12 +71,24 @@ public void Monitor()
|
||||
foreach (IHardware hardware in computer.Hardware)
|
||||
{
|
||||
Console.WriteLine("Hardware: {0}", hardware.Name);
|
||||
|
||||
foreach (IHardware subhardware in hardware.SubHardware)
|
||||
{
|
||||
Console.WriteLine("\tSubhardware: {0}", subhardware.Name);
|
||||
|
||||
foreach (ISensor sensor in subhardware.Sensors)
|
||||
{
|
||||
Console.WriteLine("\t\tSensor: {0}, value: {1}", sensor.Name, sensor.Value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ISensor sensor in hardware.Sensors)
|
||||
foreach (ISensor sensor in hardware.Sensors)
|
||||
{
|
||||
Console.WriteLine("\tSensor: {0}, value: {1}", sensor.Name, sensor.Value);
|
||||
}
|
||||
}
|
||||
|
||||
computer.Close();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user