Example #1
0
 /// <summary>
 /// Constructor for observer working on retrieving instances for a Class
 /// </summary>
 /// <param name="wmiClass">Instance of WmiClass for which to enumerate instances</param>
 public ObserverHandler(WmiClass wmiClass)
 {
     _wmiClass = wmiClass;
     _wmiClass.IsEnumerating = true;
     _isClass = true;
     _stopwatch.Start();
 }
Example #2
0
        public void NewObject(object sender, ObjectReadyEventArgs e)
        {
            ManagementObject mObject = (ManagementObject)e.NewObject;

            if (mObject.Path.IsClass && _isNamespace)
            {
                WmiClass wmiClass = new WmiClass(mObject as ManagementClass);

                ListViewItem li = new ListViewItem
                {
                    Name        = wmiClass.Path,
                    Text        = wmiClass.DisplayName,
                    ToolTipText = wmiClass.Description,
                    Tag         = wmiClass
                };

                // Add Lazy Properties, Description, and Path columns
                li.SubItems.Add(wmiClass.HasLazyProperties.ToString());
                li.SubItems.Add(wmiClass.Description);
                li.SubItems.Add(wmiClass.Path);

                _wmiNamespace.AddClass(li);
            }

            if (mObject.Path.IsInstance && _isClass)
            {
                WmiInstance wmiInstance = new WmiInstance(mObject);

                ListViewItem li = new ListViewItem
                {
                    Name        = wmiInstance.Path,
                    Text        = wmiInstance.RelativePath,
                    ToolTipText = wmiInstance.RelativePath,
                    Tag         = wmiInstance
                };

                _wmiClass.AddInstance(li);
            }
        }