More refactoring.
authorpaulwerelds
Sat, 16 Oct 2010 18:24:20 +0000
changeset 22504dbd92d1116
parent 224 be9534663a55
child 226 1e8e0c82c1f5
More refactoring.
GUI/MainForm.cs
OpenHardwareMonitor.csproj
WMIProvider/WMIProvider.cs
Wmi/Hardware.cs
Wmi/IWmiObject.cs
Wmi/Sensor.cs
Wmi/WmiProvider.cs
     1.1 --- a/GUI/MainForm.cs	Sat Oct 16 14:15:41 2010 +0000
     1.2 +++ b/GUI/MainForm.cs	Sat Oct 16 18:24:20 2010 +0000
     1.3 @@ -44,7 +44,7 @@
     1.4  using Aga.Controls.Tree;
     1.5  using Aga.Controls.Tree.NodeControls;
     1.6  using OpenHardwareMonitor.Hardware;
     1.7 -using OpenHardwareMonitor.WMIProvider;
     1.8 +using OpenHardwareMonitor.Wmi;
     1.9  
    1.10  namespace OpenHardwareMonitor.GUI {
    1.11    public partial class MainForm : Form {
     2.1 --- a/OpenHardwareMonitor.csproj	Sat Oct 16 14:15:41 2010 +0000
     2.2 +++ b/OpenHardwareMonitor.csproj	Sat Oct 16 18:24:20 2010 +0000
     2.3 @@ -128,10 +128,10 @@
     2.4      <Compile Include="GUI\SensorNode.cs" />
     2.5      <Compile Include="Utilities\EmbeddedResources.cs" />
     2.6      <Compile Include="Utilities\IconFactory.cs" />
     2.7 -    <Compile Include="WMIProvider\Hardware.cs" />
     2.8 -    <Compile Include="WMIProvider\IWmiObject.cs" />
     2.9 -    <Compile Include="WMIProvider\Sensor.cs" />
    2.10 -    <Compile Include="WMIProvider\WMIProvider.cs">
    2.11 +    <Compile Include="Wmi\Hardware.cs" />
    2.12 +    <Compile Include="Wmi\IWmiObject.cs" />
    2.13 +    <Compile Include="Wmi\Sensor.cs" />
    2.14 +    <Compile Include="Wmi\WmiProvider.cs">
    2.15        <SubType>Component</SubType>
    2.16      </Compile>
    2.17    </ItemGroup>
     3.1 --- a/WMIProvider/WMIProvider.cs	Sat Oct 16 14:15:41 2010 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,141 +0,0 @@
     3.4 -/*
     3.5 -  
     3.6 -  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     3.7 -
     3.8 -  The contents of this file are subject to the Mozilla Public License Version
     3.9 -  1.1 (the "License"); you may not use this file except in compliance with
    3.10 -  the License. You may obtain a copy of the License at
    3.11 - 
    3.12 -  http://www.mozilla.org/MPL/
    3.13 -
    3.14 -  Software distributed under the License is distributed on an "AS IS" basis,
    3.15 -  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    3.16 -  for the specific language governing rights and limitations under the License.
    3.17 -
    3.18 -  The Original Code is the Open Hardware Monitor code.
    3.19 -
    3.20 -  The Initial Developer of the Original Code is 
    3.21 -  Paul Werelds <paul@werelds.net>.
    3.22 -  Portions created by the Initial Developer are Copyright (C) 2009-2010
    3.23 -  the Initial Developer. All Rights Reserved.
    3.24 -
    3.25 -  Contributor(s):
    3.26 -
    3.27 -  Alternatively, the contents of this file may be used under the terms of
    3.28 -  either the GNU General Public License Version 2 or later (the "GPL"), or
    3.29 -  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    3.30 -  in which case the provisions of the GPL or the LGPL are applicable instead
    3.31 -  of those above. If you wish to allow use of your version of this file only
    3.32 -  under the terms of either the GPL or the LGPL, and not to allow others to
    3.33 -  use your version of this file under the terms of the MPL, indicate your
    3.34 -  decision by deleting the provisions above and replace them with the notice
    3.35 -  and other provisions required by the GPL or the LGPL. If you do not delete
    3.36 -  the provisions above, a recipient may use your version of this file under
    3.37 -  the terms of any one of the MPL, the GPL or the LGPL.
    3.38 - 
    3.39 -*/
    3.40 -
    3.41 -using System;
    3.42 -using System.Collections.Generic;
    3.43 -using System.Management.Instrumentation;
    3.44 -using OpenHardwareMonitor.Hardware;
    3.45 -
    3.46 -[assembly: Instrumented("root/OpenHardwareMonitor")]
    3.47 -
    3.48 -[System.ComponentModel.RunInstaller(true)]
    3.49 -public class InstanceInstaller : DefaultManagementProjectInstaller { }
    3.50 -
    3.51 -namespace OpenHardwareMonitor.WMIProvider {
    3.52 -  /// <summary>
    3.53 -  /// The WMI Provider.
    3.54 -  /// This class is not exposed to WMI itself.
    3.55 -  /// </summary>
    3.56 -  public class WmiProvider : IDisposable {
    3.57 -    private List<IWmiObject> _activeInstances;
    3.58 -
    3.59 -    public WmiProvider(IComputer computer) {
    3.60 -      _activeInstances = new List<IWmiObject>();
    3.61 -
    3.62 -      foreach (IHardware hardware in computer.Hardware)
    3.63 -        ComputerHardwareAdded(hardware);
    3.64 -
    3.65 -      computer.HardwareAdded += ComputerHardwareAdded;
    3.66 -      computer.HardwareRemoved += ComputerHardwareRemoved;
    3.67 -    }
    3.68 -
    3.69 -    public void Update() {
    3.70 -      foreach (IWmiObject instance in _activeInstances)
    3.71 -        instance.Update();
    3.72 -    }
    3.73 -
    3.74 -    #region Eventhandlers
    3.75 -    
    3.76 -    private void ComputerHardwareAdded(IHardware hardware) {
    3.77 -      if (!Exists(hardware.Identifier.ToString())) {
    3.78 -        foreach (ISensor sensor in hardware.Sensors)
    3.79 -          HardwareSensorAdded(sensor);
    3.80 -
    3.81 -        hardware.SensorAdded += HardwareSensorAdded;
    3.82 -        hardware.SensorRemoved += HardwareSensorRemoved;
    3.83 -
    3.84 -        Hardware hw = new Hardware(hardware);
    3.85 -        _activeInstances.Add(hw);
    3.86 -
    3.87 -        Instrumentation.Publish(hw);
    3.88 -      }
    3.89 -
    3.90 -      foreach (IHardware subHardware in hardware.SubHardware)
    3.91 -        ComputerHardwareAdded(subHardware);
    3.92 -    }
    3.93 -
    3.94 -    private void HardwareSensorAdded(ISensor data) {
    3.95 -      Sensor sensor = new Sensor(data);
    3.96 -      _activeInstances.Add(sensor);
    3.97 -
    3.98 -      Instrumentation.Publish(sensor);
    3.99 -    }
   3.100 -
   3.101 -    private void ComputerHardwareRemoved(IHardware hardware) {
   3.102 -      hardware.SensorAdded -= HardwareSensorAdded;
   3.103 -      hardware.SensorRemoved -= HardwareSensorRemoved;
   3.104 -      
   3.105 -      foreach (ISensor sensor in hardware.Sensors) 
   3.106 -        HardwareSensorRemoved(sensor);
   3.107 -      
   3.108 -      foreach (IHardware subHardware in hardware.SubHardware)
   3.109 -        ComputerHardwareRemoved(subHardware);
   3.110 -
   3.111 -      RevokeInstance(hardware.Identifier.ToString());
   3.112 -    }
   3.113 -
   3.114 -    private void HardwareSensorRemoved(ISensor sensor) {
   3.115 -      RevokeInstance(sensor.Identifier.ToString());
   3.116 -    }
   3.117 -
   3.118 -    #endregion
   3.119 -
   3.120 -    #region Helpers
   3.121 -    
   3.122 -    private bool Exists(string identifier) {
   3.123 -      return _activeInstances.Exists(h => h.Identifier == identifier);
   3.124 -    }
   3.125 -
   3.126 -    private void RevokeInstance(string identifier) {
   3.127 -      int instanceIndex = _activeInstances.FindIndex(
   3.128 -        item => item.Identifier == identifier.ToString()
   3.129 -      );
   3.130 -
   3.131 -      Instrumentation.Revoke(_activeInstances[instanceIndex]);
   3.132 -
   3.133 -      _activeInstances.RemoveAt(instanceIndex);
   3.134 -    }
   3.135 -
   3.136 -    #endregion
   3.137 -
   3.138 -    public void Dispose() {
   3.139 -      foreach (IWmiObject instance in _activeInstances)
   3.140 -        Instrumentation.Revoke(instance);
   3.141 -      _activeInstances = null;
   3.142 -    }
   3.143 -  }
   3.144 -}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/Wmi/Hardware.cs	Sat Oct 16 18:24:20 2010 +0000
     4.3 @@ -0,0 +1,60 @@
     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 +using System.Management.Instrumentation;
    4.42 +using OpenHardwareMonitor.Hardware;
    4.43 +
    4.44 +namespace OpenHardwareMonitor.Wmi {
    4.45 +  [InstrumentationClass(InstrumentationType.Instance)]
    4.46 +  public class Hardware : IWmiObject {
    4.47 +    #region WMI Exposed
    4.48 +    
    4.49 +    public string HardwareType { get; private set; }
    4.50 +    public string Identifier { get; private set; }
    4.51 +    public string Name { get; private set; }
    4.52 +
    4.53 +    #endregion
    4.54 +
    4.55 +    public Hardware(IHardware hardware) {
    4.56 +      Name = hardware.Name;
    4.57 +      Identifier = hardware.Identifier.ToString();
    4.58 +      HardwareType = hardware.HardwareType.ToString();
    4.59 +    }
    4.60 +
    4.61 +    public void Update() { }
    4.62 +  }
    4.63 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/Wmi/IWmiObject.cs	Sat Oct 16 18:24:20 2010 +0000
     5.3 @@ -0,0 +1,47 @@
     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 +namespace OpenHardwareMonitor.Wmi {
    5.42 +  interface IWmiObject {
    5.43 +    // Both of these get exposed to WMI
    5.44 +    string Name { get; }
    5.45 +    string Identifier { get; }
    5.46 +
    5.47 +    // Not exposed.
    5.48 +    void Update();
    5.49 +  }
    5.50 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/Wmi/Sensor.cs	Sat Oct 16 18:24:20 2010 +0000
     6.3 @@ -0,0 +1,81 @@
     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.Management.Instrumentation;
    6.42 +using OpenHardwareMonitor.Hardware;
    6.43 +using OpenHardwareMonitor.Wmi;
    6.44 +
    6.45 +namespace OpenHardwareMonitor.Wmi {
    6.46 +  [InstrumentationClass(InstrumentationType.Instance)]
    6.47 +  public class Sensor : IWmiObject {
    6.48 +    private ISensor sensor;
    6.49 +
    6.50 +    #region WMI Exposed
    6.51 +
    6.52 +    public string SensorType { get; private set; }
    6.53 +    public string Identifier { get; private set; }
    6.54 +    public string Parent { get; private set; }
    6.55 +    public string Name { get; private set; }
    6.56 +    public float Value { get; private set; }
    6.57 +    public float Min { get; private set; }
    6.58 +    public float Max { get; private set; }
    6.59 +    public int Index { get; private set; }
    6.60 +
    6.61 +    #endregion
    6.62 +
    6.63 +    public Sensor(ISensor sensor) {
    6.64 +      Name = sensor.Name;
    6.65 +      Index = sensor.Index;
    6.66 +
    6.67 +      SensorType = sensor.SensorType.ToString();
    6.68 +      Identifier = sensor.Identifier.ToString();
    6.69 +      Parent = sensor.Hardware.Identifier.ToString();
    6.70 +
    6.71 +      this.sensor = sensor;
    6.72 +    }
    6.73 +    
    6.74 +    public void Update() {
    6.75 +      Value = (sensor.Value != null) ? (float)sensor.Value : 0;
    6.76 +
    6.77 +      if (sensor.Min != null)
    6.78 +        Min = (float)sensor.Min;
    6.79 +
    6.80 +      if (sensor.Max != null)
    6.81 +        Max = (float)sensor.Max;
    6.82 +    }
    6.83 +  }
    6.84 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/Wmi/WmiProvider.cs	Sat Oct 16 18:24:20 2010 +0000
     7.3 @@ -0,0 +1,142 @@
     7.4 +/*
     7.5 +  
     7.6 +  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     7.7 +
     7.8 +  The contents of this file are subject to the Mozilla Public License Version
     7.9 +  1.1 (the "License"); you may not use this file except in compliance with
    7.10 +  the License. You may obtain a copy of the License at
    7.11 + 
    7.12 +  http://www.mozilla.org/MPL/
    7.13 +
    7.14 +  Software distributed under the License is distributed on an "AS IS" basis,
    7.15 +  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    7.16 +  for the specific language governing rights and limitations under the License.
    7.17 +
    7.18 +  The Original Code is the Open Hardware Monitor code.
    7.19 +
    7.20 +  The Initial Developer of the Original Code is 
    7.21 +  Paul Werelds <paul@werelds.net>.
    7.22 +  Portions created by the Initial Developer are Copyright (C) 2009-2010
    7.23 +  the Initial Developer. All Rights Reserved.
    7.24 +
    7.25 +  Contributor(s):
    7.26 +
    7.27 +  Alternatively, the contents of this file may be used under the terms of
    7.28 +  either the GNU General Public License Version 2 or later (the "GPL"), or
    7.29 +  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    7.30 +  in which case the provisions of the GPL or the LGPL are applicable instead
    7.31 +  of those above. If you wish to allow use of your version of this file only
    7.32 +  under the terms of either the GPL or the LGPL, and not to allow others to
    7.33 +  use your version of this file under the terms of the MPL, indicate your
    7.34 +  decision by deleting the provisions above and replace them with the notice
    7.35 +  and other provisions required by the GPL or the LGPL. If you do not delete
    7.36 +  the provisions above, a recipient may use your version of this file under
    7.37 +  the terms of any one of the MPL, the GPL or the LGPL.
    7.38 + 
    7.39 +*/
    7.40 +
    7.41 +using System;
    7.42 +using System.Collections.Generic;
    7.43 +using System.Management.Instrumentation;
    7.44 +using OpenHardwareMonitor.Hardware;
    7.45 +using OpenHardwareMonitor.Wmi;
    7.46 +
    7.47 +[assembly: Instrumented("root/OpenHardwareMonitor")]
    7.48 +
    7.49 +[System.ComponentModel.RunInstaller(true)]
    7.50 +public class InstanceInstaller : DefaultManagementProjectInstaller { }
    7.51 +
    7.52 +namespace OpenHardwareMonitor.Wmi {
    7.53 +  /// <summary>
    7.54 +  /// The WMI Provider.
    7.55 +  /// This class is not exposed to WMI itself.
    7.56 +  /// </summary>
    7.57 +  public class WmiProvider : IDisposable {
    7.58 +    private List<IWmiObject> activeInstances;
    7.59 +
    7.60 +    public WmiProvider(IComputer computer) {
    7.61 +      activeInstances = new List<IWmiObject>();
    7.62 +
    7.63 +      foreach (IHardware hardware in computer.Hardware)
    7.64 +        ComputerHardwareAdded(hardware);
    7.65 +
    7.66 +      computer.HardwareAdded += ComputerHardwareAdded;
    7.67 +      computer.HardwareRemoved += ComputerHardwareRemoved;
    7.68 +    }
    7.69 +
    7.70 +    public void Update() {
    7.71 +      foreach (IWmiObject instance in activeInstances)
    7.72 +        instance.Update();
    7.73 +    }
    7.74 +
    7.75 +    #region Eventhandlers
    7.76 +    
    7.77 +    private void ComputerHardwareAdded(IHardware hardware) {
    7.78 +      if (!Exists(hardware.Identifier.ToString())) {
    7.79 +        foreach (ISensor sensor in hardware.Sensors)
    7.80 +          HardwareSensorAdded(sensor);
    7.81 +
    7.82 +        hardware.SensorAdded += HardwareSensorAdded;
    7.83 +        hardware.SensorRemoved += HardwareSensorRemoved;
    7.84 +
    7.85 +        Hardware hw = new Hardware(hardware);
    7.86 +        activeInstances.Add(hw);
    7.87 +
    7.88 +        Instrumentation.Publish(hw);
    7.89 +      }
    7.90 +
    7.91 +      foreach (IHardware subHardware in hardware.SubHardware)
    7.92 +        ComputerHardwareAdded(subHardware);
    7.93 +    }
    7.94 +
    7.95 +    private void HardwareSensorAdded(ISensor data) {
    7.96 +      Sensor sensor = new Sensor(data);
    7.97 +      activeInstances.Add(sensor);
    7.98 +
    7.99 +      Instrumentation.Publish(sensor);
   7.100 +    }
   7.101 +
   7.102 +    private void ComputerHardwareRemoved(IHardware hardware) {
   7.103 +      hardware.SensorAdded -= HardwareSensorAdded;
   7.104 +      hardware.SensorRemoved -= HardwareSensorRemoved;
   7.105 +      
   7.106 +      foreach (ISensor sensor in hardware.Sensors) 
   7.107 +        HardwareSensorRemoved(sensor);
   7.108 +      
   7.109 +      foreach (IHardware subHardware in hardware.SubHardware)
   7.110 +        ComputerHardwareRemoved(subHardware);
   7.111 +
   7.112 +      RevokeInstance(hardware.Identifier.ToString());
   7.113 +    }
   7.114 +
   7.115 +    private void HardwareSensorRemoved(ISensor sensor) {
   7.116 +      RevokeInstance(sensor.Identifier.ToString());
   7.117 +    }
   7.118 +
   7.119 +    #endregion
   7.120 +
   7.121 +    #region Helpers
   7.122 +    
   7.123 +    private bool Exists(string identifier) {
   7.124 +      return activeInstances.Exists(h => h.Identifier == identifier);
   7.125 +    }
   7.126 +
   7.127 +    private void RevokeInstance(string identifier) {
   7.128 +      int instanceIndex = activeInstances.FindIndex(
   7.129 +        item => item.Identifier == identifier.ToString()
   7.130 +      );
   7.131 +
   7.132 +      Instrumentation.Revoke(activeInstances[instanceIndex]);
   7.133 +
   7.134 +      activeInstances.RemoveAt(instanceIndex);
   7.135 +    }
   7.136 +
   7.137 +    #endregion
   7.138 +
   7.139 +    public void Dispose() {
   7.140 +      foreach (IWmiObject instance in activeInstances)
   7.141 +        Instrumentation.Revoke(instance);
   7.142 +      activeInstances = null;
   7.143 +    }
   7.144 +  }
   7.145 +}