1.1 --- a/Hardware/Computer.cs Tue Sep 21 10:33:28 2010 +0000
1.2 +++ b/Hardware/Computer.cs Tue Sep 21 20:32:36 2010 +0000
1.3 @@ -45,22 +45,18 @@
1.4
1.5 public class Computer : IComputer {
1.6
1.7 - private List<IGroup> groups = new List<IGroup>();
1.8 + private readonly List<IGroup> groups = new List<IGroup>();
1.9 + private readonly ISettings settings;
1.10
1.11 - private bool open = false;
1.12 - private bool hddEnabled = false;
1.13 - private ISettings settings;
1.14 + private bool open;
1.15 + private bool hddEnabled;
1.16
1.17 public Computer() {
1.18 this.settings = new Settings();
1.19 }
1.20
1.21 public Computer(ISettings settings) {
1.22 - if (settings != null)
1.23 - this.settings = settings;
1.24 - else {
1.25 - this.settings = new Settings();
1.26 - }
1.27 + this.settings = settings ?? new Settings();
1.28 }
1.29
1.30 private void Add(IGroup group) {
1.31 @@ -141,7 +137,7 @@
1.32 writer.WriteLine();
1.33 }
1.34
1.35 - private int CompareSensor(ISensor a, ISensor b) {
1.36 + private static int CompareSensor(ISensor a, ISensor b) {
1.37 int c = a.SensorType.CompareTo(b.SensorType);
1.38 if (c == 0)
1.39 return a.Index.CompareTo(b.Index);
1.40 @@ -149,13 +145,14 @@
1.41 return c;
1.42 }
1.43
1.44 - private void ReportHardwareSensorTree(IHardware hardware, TextWriter w,
1.45 - string space) {
1.46 + private static void ReportHardwareSensorTree(
1.47 + IHardware hardware, TextWriter w, string space)
1.48 + {
1.49 w.WriteLine("{0}|", space);
1.50 w.WriteLine("{0}+-+ {1} ({2})",
1.51 space, hardware.Name, hardware.Identifier);
1.52 ISensor[] sensors = hardware.Sensors;
1.53 - Array.Sort<ISensor>(sensors, CompareSensor);
1.54 + Array.Sort(sensors, CompareSensor);
1.55 foreach (ISensor sensor in sensors) {
1.56 w.WriteLine("{0}| +- {1}[{2}] : {3} : {4}",
1.57 space, sensor.SensorType, sensor.Index,
1.58 @@ -166,13 +163,14 @@
1.59 ReportHardwareSensorTree(subHardware, w, "| ");
1.60 }
1.61
1.62 - private void ReportHardwareParameterTree(IHardware hardware, TextWriter w,
1.63 - string space) {
1.64 + private static void ReportHardwareParameterTree(
1.65 + IHardware hardware, TextWriter w, string space)
1.66 + {
1.67 w.WriteLine("{0}|", space);
1.68 w.WriteLine("{0}+-+ {1} ({2})",
1.69 space, hardware.Name, hardware.Identifier);
1.70 ISensor[] sensors = hardware.Sensors;
1.71 - Array.Sort<ISensor>(sensors, CompareSensor);
1.72 + Array.Sort(sensors, CompareSensor);
1.73 foreach (ISensor sensor in sensors) {
1.74 if (sensor.Parameters.Length > 0) {
1.75 w.WriteLine("{0}| +- {1}[{2}] : {3}",
1.76 @@ -189,7 +187,7 @@
1.77 ReportHardwareParameterTree(subHardware, w, "| ");
1.78 }
1.79
1.80 - private void ReportHardware(IHardware hardware, TextWriter w) {
1.81 + private static void ReportHardware(IHardware hardware, TextWriter w) {
1.82 string hardwareReport = hardware.GetReport();
1.83 if (!string.IsNullOrEmpty(hardwareReport)) {
1.84 NewSection(w);