Changed a few types to internal (instead of public) in the Open Hardware Monitor library.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
12 using System.Globalization;
14 namespace OpenHardwareMonitor.Hardware {
16 internal struct ParameterDescription {
17 private readonly string name;
18 private readonly string description;
19 private readonly float defaultValue;
21 public ParameterDescription(string name, string description,
24 this.description = description;
25 this.defaultValue = defaultValue;
28 public string Name { get { return name; } }
30 public string Description { get { return description; } }
32 public float DefaultValue { get { return defaultValue; } }
35 internal class Parameter : IParameter {
36 private readonly ISensor sensor;
37 private ParameterDescription description;
39 private bool isDefault;
40 private readonly ISettings settings;
42 public Parameter(ParameterDescription description, ISensor sensor,
46 this.description = description;
47 this.settings = settings;
48 this.isDefault = !settings.Contains(Identifier.ToString());
49 this.value = description.DefaultValue;
50 if (!this.isDefault) {
51 if (!float.TryParse(settings.GetValue(Identifier.ToString(), "0"),
53 CultureInfo.InvariantCulture,
55 this.value = description.DefaultValue;
59 public ISensor Sensor {
65 public Identifier Identifier {
67 return new Identifier(sensor.Identifier, "parameter",
68 Name.Replace(" ", "").ToLowerInvariant());
72 public string Name { get { return description.Name; } }
74 public string Description { get { return description.Description; } }
81 this.isDefault = false;
83 this.settings.SetValue(Identifier.ToString(), value.ToString(
84 CultureInfo.InvariantCulture));
88 public float DefaultValue {
89 get { return description.DefaultValue; }
92 public bool IsDefault {
93 get { return isDefault; }
95 this.isDefault = value;
97 this.value = description.DefaultValue;
98 this.settings.Remove(Identifier.ToString());
103 public void Accept(IVisitor visitor) {
105 throw new ArgumentNullException("visitor");
106 visitor.VisitParameter(this);
109 public void Traverse(IVisitor visitor) { }