Added license to the WMI stuff and refactored a few things a little.
1.1 --- a/OpenHardwareMonitor.csproj Sat Oct 16 13:29:06 2010 +0000
1.2 +++ b/OpenHardwareMonitor.csproj Sat Oct 16 14:15:41 2010 +0000
1.3 @@ -129,7 +129,7 @@
1.4 <Compile Include="Utilities\EmbeddedResources.cs" />
1.5 <Compile Include="Utilities\IconFactory.cs" />
1.6 <Compile Include="WMIProvider\Hardware.cs" />
1.7 - <Compile Include="WMIProvider\IWmiClass.cs" />
1.8 + <Compile Include="WMIProvider\IWmiObject.cs" />
1.9 <Compile Include="WMIProvider\Sensor.cs" />
1.10 <Compile Include="WMIProvider\WMIProvider.cs">
1.11 <SubType>Component</SubType>
2.1 --- a/WMIProvider/Hardware.cs Sat Oct 16 13:29:06 2010 +0000
2.2 +++ b/WMIProvider/Hardware.cs Sat Oct 16 14:15:41 2010 +0000
2.3 @@ -1,13 +1,54 @@
2.4 -using System.Management.Instrumentation;
2.5 +/*
2.6 +
2.7 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
2.8 +
2.9 + The contents of this file are subject to the Mozilla Public License Version
2.10 + 1.1 (the "License"); you may not use this file except in compliance with
2.11 + the License. You may obtain a copy of the License at
2.12 +
2.13 + http://www.mozilla.org/MPL/
2.14 +
2.15 + Software distributed under the License is distributed on an "AS IS" basis,
2.16 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2.17 + for the specific language governing rights and limitations under the License.
2.18 +
2.19 + The Original Code is the Open Hardware Monitor code.
2.20 +
2.21 + The Initial Developer of the Original Code is
2.22 + Paul Werelds <paul@werelds.net>.
2.23 + Portions created by the Initial Developer are Copyright (C) 2009-2010
2.24 + the Initial Developer. All Rights Reserved.
2.25 +
2.26 + Contributor(s):
2.27 +
2.28 + Alternatively, the contents of this file may be used under the terms of
2.29 + either the GNU General Public License Version 2 or later (the "GPL"), or
2.30 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2.31 + in which case the provisions of the GPL or the LGPL are applicable instead
2.32 + of those above. If you wish to allow use of your version of this file only
2.33 + under the terms of either the GPL or the LGPL, and not to allow others to
2.34 + use your version of this file under the terms of the MPL, indicate your
2.35 + decision by deleting the provisions above and replace them with the notice
2.36 + and other provisions required by the GPL or the LGPL. If you do not delete
2.37 + the provisions above, a recipient may use your version of this file under
2.38 + the terms of any one of the MPL, the GPL or the LGPL.
2.39 +
2.40 +*/
2.41 +
2.42 +using System.Management.Instrumentation;
2.43 using OpenHardwareMonitor.Hardware;
2.44
2.45 namespace OpenHardwareMonitor.WMIProvider {
2.46 [InstrumentationClass(InstrumentationType.Instance)]
2.47 - public class Hardware : IWmiClass {
2.48 + public class Hardware : IWmiObject {
2.49 + #region WMI Exposed
2.50 +
2.51 public string HardwareType { get; private set; }
2.52 public string Identifier { get; private set; }
2.53 public string Name { get; private set; }
2.54
2.55 + #endregion
2.56 +
2.57 public Hardware(IHardware hardware) {
2.58 Name = hardware.Name;
2.59 Identifier = hardware.Identifier.ToString();
3.1 --- a/WMIProvider/IWmiClass.cs Sat Oct 16 13:29:06 2010 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,8 +0,0 @@
3.4 -namespace OpenHardwareMonitor.WMIProvider {
3.5 - interface IWmiClass {
3.6 - string Name { get; }
3.7 - string Identifier { get; }
3.8 -
3.9 - void Update();
3.10 - }
3.11 -}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/WMIProvider/IWmiObject.cs Sat Oct 16 14:15:41 2010 +0000
4.3 @@ -0,0 +1,47 @@
4.4 +/*
4.5 +
4.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
4.7 +
4.8 + The contents of this file are subject to the Mozilla Public License Version
4.9 + 1.1 (the "License"); you may not use this file except in compliance with
4.10 + the License. You may obtain a copy of the License at
4.11 +
4.12 + http://www.mozilla.org/MPL/
4.13 +
4.14 + Software distributed under the License is distributed on an "AS IS" basis,
4.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4.16 + for the specific language governing rights and limitations under the License.
4.17 +
4.18 + The Original Code is the Open Hardware Monitor code.
4.19 +
4.20 + The Initial Developer of the Original Code is
4.21 + Paul Werelds <paul@werelds.net>.
4.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
4.23 + the Initial Developer. All Rights Reserved.
4.24 +
4.25 + Contributor(s):
4.26 +
4.27 + Alternatively, the contents of this file may be used under the terms of
4.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
4.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4.30 + in which case the provisions of the GPL or the LGPL are applicable instead
4.31 + of those above. If you wish to allow use of your version of this file only
4.32 + under the terms of either the GPL or the LGPL, and not to allow others to
4.33 + use your version of this file under the terms of the MPL, indicate your
4.34 + decision by deleting the provisions above and replace them with the notice
4.35 + and other provisions required by the GPL or the LGPL. If you do not delete
4.36 + the provisions above, a recipient may use your version of this file under
4.37 + the terms of any one of the MPL, the GPL or the LGPL.
4.38 +
4.39 +*/
4.40 +
4.41 +namespace OpenHardwareMonitor.WMIProvider {
4.42 + interface IWmiObject {
4.43 + // Both of these get exposed to WMI
4.44 + string Name { get; }
4.45 + string Identifier { get; }
4.46 +
4.47 + // Not exposed.
4.48 + void Update();
4.49 + }
4.50 +}
5.1 --- a/WMIProvider/Sensor.cs Sat Oct 16 13:29:06 2010 +0000
5.2 +++ b/WMIProvider/Sensor.cs Sat Oct 16 14:15:41 2010 +0000
5.3 @@ -1,11 +1,49 @@
5.4 +/*
5.5 +
5.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
5.7 +
5.8 + The contents of this file are subject to the Mozilla Public License Version
5.9 + 1.1 (the "License"); you may not use this file except in compliance with
5.10 + the License. You may obtain a copy of the License at
5.11 +
5.12 + http://www.mozilla.org/MPL/
5.13 +
5.14 + Software distributed under the License is distributed on an "AS IS" basis,
5.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
5.16 + for the specific language governing rights and limitations under the License.
5.17 +
5.18 + The Original Code is the Open Hardware Monitor code.
5.19 +
5.20 + The Initial Developer of the Original Code is
5.21 + Paul Werelds <paul@werelds.net>.
5.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
5.23 + the Initial Developer. All Rights Reserved.
5.24 +
5.25 + Contributor(s):
5.26 +
5.27 + Alternatively, the contents of this file may be used under the terms of
5.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
5.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
5.30 + in which case the provisions of the GPL or the LGPL are applicable instead
5.31 + of those above. If you wish to allow use of your version of this file only
5.32 + under the terms of either the GPL or the LGPL, and not to allow others to
5.33 + use your version of this file under the terms of the MPL, indicate your
5.34 + decision by deleting the provisions above and replace them with the notice
5.35 + and other provisions required by the GPL or the LGPL. If you do not delete
5.36 + the provisions above, a recipient may use your version of this file under
5.37 + the terms of any one of the MPL, the GPL or the LGPL.
5.38 +
5.39 +*/
5.40 +
5.41 using System.Management.Instrumentation;
5.42 using OpenHardwareMonitor.Hardware;
5.43
5.44 namespace OpenHardwareMonitor.WMIProvider {
5.45 [InstrumentationClass(InstrumentationType.Instance)]
5.46 - public class Sensor : IWmiClass {
5.47 + public class Sensor : IWmiObject {
5.48 + private ISensor sensor;
5.49
5.50 - private ISensor _sensor;
5.51 + #region WMI Exposed
5.52
5.53 public string SensorType { get; private set; }
5.54 public string Identifier { get; private set; }
5.55 @@ -16,25 +54,27 @@
5.56 public float Max { get; private set; }
5.57 public int Index { get; private set; }
5.58
5.59 - public Sensor(ISensor sensor) {
5.60 - Name = sensor.Name;
5.61 - Index = sensor.Index;
5.62 + #endregion
5.63
5.64 - SensorType = sensor.SensorType.ToString();
5.65 - Identifier = sensor.Identifier.ToString();
5.66 - Parent = sensor.Hardware.Identifier.ToString();
5.67 + public Sensor(ISensor data) {
5.68 + Name = data.Name;
5.69 + Index = data.Index;
5.70
5.71 - _sensor = sensor;
5.72 + SensorType = data.SensorType.ToString();
5.73 + Identifier = data.Identifier.ToString();
5.74 + Parent = data.Hardware.Identifier.ToString();
5.75 +
5.76 + sensor = data;
5.77 }
5.78
5.79 public void Update() {
5.80 - Value = (_sensor.Value != null) ? (float)_sensor.Value : 0;
5.81 + Value = (sensor.Value != null) ? (float)sensor.Value : 0;
5.82
5.83 - if (_sensor.Min != null)
5.84 - Min = (float)_sensor.Min;
5.85 + if (sensor.Min != null)
5.86 + Min = (float)sensor.Min;
5.87
5.88 - if (_sensor.Max != null)
5.89 - Max = (float)_sensor.Max;
5.90 + if (sensor.Max != null)
5.91 + Max = (float)sensor.Max;
5.92 }
5.93 }
5.94 }
6.1 --- a/WMIProvider/WMIProvider.cs Sat Oct 16 13:29:06 2010 +0000
6.2 +++ b/WMIProvider/WMIProvider.cs Sat Oct 16 14:15:41 2010 +0000
6.3 @@ -1,3 +1,40 @@
6.4 +/*
6.5 +
6.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
6.7 +
6.8 + The contents of this file are subject to the Mozilla Public License Version
6.9 + 1.1 (the "License"); you may not use this file except in compliance with
6.10 + the License. You may obtain a copy of the License at
6.11 +
6.12 + http://www.mozilla.org/MPL/
6.13 +
6.14 + Software distributed under the License is distributed on an "AS IS" basis,
6.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
6.16 + for the specific language governing rights and limitations under the License.
6.17 +
6.18 + The Original Code is the Open Hardware Monitor code.
6.19 +
6.20 + The Initial Developer of the Original Code is
6.21 + Paul Werelds <paul@werelds.net>.
6.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
6.23 + the Initial Developer. All Rights Reserved.
6.24 +
6.25 + Contributor(s):
6.26 +
6.27 + Alternatively, the contents of this file may be used under the terms of
6.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
6.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
6.30 + in which case the provisions of the GPL or the LGPL are applicable instead
6.31 + of those above. If you wish to allow use of your version of this file only
6.32 + under the terms of either the GPL or the LGPL, and not to allow others to
6.33 + use your version of this file under the terms of the MPL, indicate your
6.34 + decision by deleting the provisions above and replace them with the notice
6.35 + and other provisions required by the GPL or the LGPL. If you do not delete
6.36 + the provisions above, a recipient may use your version of this file under
6.37 + the terms of any one of the MPL, the GPL or the LGPL.
6.38 +
6.39 +*/
6.40 +
6.41 using System;
6.42 using System.Collections.Generic;
6.43 using System.Management.Instrumentation;
6.44 @@ -9,11 +46,15 @@
6.45 public class InstanceInstaller : DefaultManagementProjectInstaller { }
6.46
6.47 namespace OpenHardwareMonitor.WMIProvider {
6.48 + /// <summary>
6.49 + /// The WMI Provider.
6.50 + /// This class is not exposed to WMI itself.
6.51 + /// </summary>
6.52 public class WmiProvider : IDisposable {
6.53 - private List<IWmiClass> _activeInstances;
6.54 + private List<IWmiObject> _activeInstances;
6.55
6.56 public WmiProvider(IComputer computer) {
6.57 - _activeInstances = new List<IWmiClass>();
6.58 + _activeInstances = new List<IWmiObject>();
6.59
6.60 foreach (IHardware hardware in computer.Hardware)
6.61 ComputerHardwareAdded(hardware);
6.62 @@ -23,7 +64,7 @@
6.63 }
6.64
6.65 public void Update() {
6.66 - foreach (IWmiClass instance in _activeInstances)
6.67 + foreach (IWmiObject instance in _activeInstances)
6.68 instance.Update();
6.69 }
6.70
6.71 @@ -92,7 +133,7 @@
6.72 #endregion
6.73
6.74 public void Dispose() {
6.75 - foreach (IWmiClass instance in _activeInstances)
6.76 + foreach (IWmiObject instance in _activeInstances)
6.77 Instrumentation.Revoke(instance);
6.78 _activeInstances = null;
6.79 }