Пример #1
0
        //******************************************************
        //CompareTo
        //******************************************************
        /// <summary>
        ///    <para>Compares this object to another, based on specified options</para>
        /// </summary>
        /// <param name='otherObject'>The object to compare to </param>
        /// <param name='settings'>Options on how to compare the objects </param>
        /// <returns>
        ///    TRUE if the objects compared are equal
        ///    according to the give options, FALSE otherwise.
        /// </returns>
        public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
        {
            if (null == otherObject)
            {
                throw new ArgumentNullException("otherObject");
            }

            Initialize();
            bool result = false;

            if (null != wbemObject)
            {
                int status = (int)ManagementStatus.NoError;

                otherObject.Initialize();

                status = wbemObject.CompareTo_((int)settings, otherObject.wbemObject);

                if ((int)ManagementStatus.Different == status)
                {
                    result = false;
                }
                else if ((int)ManagementStatus.NoError == status)
                {
                    result = true;
                }
                else if ((status & 0xfffff000) == 0x80041000)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                }
                else if (status < 0)
                {
                    Marshal.ThrowExceptionForHR(status);
                }
            }

            return(result);
        }