public override bool Equals(object other)
 {
     if (other is WMIPropertyDescriptor)
     {
         WMIPropertyDescriptor descriptor = (WMIPropertyDescriptor)other;
         return((descriptor.propName == propName) &&
                (descriptor.mgmtObj.Path.Path == mgmtObj.Path.Path));
     }
     return(false);
 }
        /// <summary>
        ///     Retrieves an array of properties that the given component instance
        ///     provides.  This may differ from the set of properties the class
        ///     provides.  If the component is sited, the site may add or remove
        ///     additional properties.
        /// </summary>
        /// <returns>
        ///     an array of properties this component surfaces.
        /// </returns>
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
        {
            PropertyCollection props = mgmtObj.Properties;

            PropertyCollection.PropertyEnumerator eProps = props.GetEnumerator();

            PropertyDescriptor[] propDescrArray = new PropertyDescriptor[props.Count + NUM_OF_SYSTEM_PROPS];
            if (propDescrArray.Length != 0)
            {
                int counter = 0;
                while (eProps.MoveNext())
                {
                    Property curProp = eProps.Current;

                    if (GENUS == 2)
                    {
                        //get the property on the class object: to get to "Values" qualifier
                        curProp = mgmtClassObj.Properties[curProp.Name];
                    }

                    /*
                     * if (WmiHelper.IsValueMap(curProp))
                     * {
                     *      //MessageBox.Show("Value map property " + ((ISWbemProperty)eProps.Current).Name);
                     *      propDescrArray[counter++] = new WMIEnumPropertyDescriptor(mgmtObj,
                     *                                                                                                                      mgmtClassObj,
                     *                                                                                                                      mgmtObj,
                     *                                                                                                                      mgmtClassObj,
                     *                                                                                                                      curProp.Name,
                     *                                                                                                                      !IsNewInstance);
                     *
                     * }
                     * else
                     */
                    {
                        propDescrArray[counter++] = new WMIPropertyDescriptor(mgmtObj,
                                                                              mgmtClassObj,
                                                                              curProp.Name,
                                                                              !IsNewInstance);
                    }
                }

                //add system properties
                IDictionaryEnumerator enumSys = (IDictionaryEnumerator)((IEnumerable)SystemPropertyDictionary).GetEnumerator();

                while (enumSys.MoveNext())
                {
                    propDescrArray[counter++] = new WMISystemPropertyDescriptor(mgmtObj,
                                                                                enumSys.Key.ToString(),
                                                                                enumSys.Value);
                }
            }

            return(new PropertyDescriptorCollection(propDescrArray));
        }
        /// <summary>
        ///     Retrieves an array of properties that the given component instance
        ///     provides.  This may differ from the set of properties the class
        ///     provides.  If the component is sited, the site may add or remove
        ///     additional properties.
        /// </summary>
        /// <returns>
        ///     an array of properties this component surfaces.
        /// </returns>
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
        {
            //NOTE: this re-initializing of mgmtObj and mgmtClassObj is a workaround:
            //apparently, the cached pointers that were created on a different thread
            //don't work: Interop marshalling problems?

            mgmtObj = null;
            mgmtObj = new ManagementObject(wmiObj.Path_.Path);

            mgmtClassObj = null;
            mgmtClassObj = new ManagementObject(wmiClassObj.Path_.Path);

            ISWbemPropertySet props  = (ISWbemPropertySet)wmiObj.Properties_;
            IEnumerator       eProps = ((IEnumerable)props).GetEnumerator();

            PropertyDescriptor[] propDescrArray = new PropertyDescriptor[((ISWbemPropertySet)props).Count + NUM_OF_SYSTEM_PROPS];
            if (propDescrArray.Length != 0)
            {
                int counter = 0;
                while (eProps.MoveNext())
                {
                    ISWbemProperty curProp = (ISWbemProperty)eProps.Current;

                    if (GENUS == 2)
                    {
                        //get the property on the class object: to get to "Values" qualifier
                        curProp = wmiClassObj.Properties_.Item(curProp.Name, 0);
                    }

                    /*
                     * if (WmiHelper.IsValueMap(curProp))
                     * {
                     *      //MessageBox.Show("Value map property " + ((ISWbemProperty)eProps.Current).Name);
                     *      propDescrArray[counter++] = new WMIEnumPropertyDescriptor(mgmtObj,
                     *                                                                                                                      mgmtClassObj,
                     *                                                                                                                      wmiObj,
                     *                                                                                                                      wmiClassObj,
                     *                                                                                                                      curProp.Name,
                     *                                                                                                                      !IsNewInstance);
                     *
                     * }
                     * else
                     */
                    {
                        propDescrArray[counter++] = new WMIPropertyDescriptor(mgmtObj,
                                                                              mgmtClassObj,
                                                                              wmiObj,
                                                                              wmiClassObj,
                                                                              curProp.Name,
                                                                              !IsNewInstance);
                    }
                }

                //add system properties
                IDictionaryEnumerator enumSys = (IDictionaryEnumerator)((IEnumerable)SystemPropertyDictionary).GetEnumerator();

                while (enumSys.MoveNext())
                {
                    propDescrArray[counter++] = new WMISystemPropertyDescriptor(wmiObj,
                                                                                enumSys.Key.ToString(),
                                                                                enumSys.Value);
                }
            }

            return(new PropertyDescriptorCollection(propDescrArray));
        }