From af796fe6ba2790e72e0d21c91f8ddbc6c627b5eb Mon Sep 17 00:00:00 2001 From: Pomian Date: Sat, 14 Nov 2020 20:18:25 +0100 Subject: [PATCH] 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. --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60d583f..c837495 100644 --- a/README.md +++ b/README.md @@ -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(); } ```