Esempio n. 1
0
        public ManagementObject CreateInstance()
        {
            ManagementObject managementObject = null;

            if (base.PutButNotGot)
            {
                base.Get();
                base.PutButNotGot = false;
            }
            IWbemClassObjectFreeThreaded wbemClassObjectFreeThreaded = null;
            int num = base.wbemObject.SpawnInstance_(0, out wbemClassObjectFreeThreaded);

            if (num < 0)
            {
                if (((long)num & (long)-4096) != (long)-2147217408)
                {
                    Marshal.ThrowExceptionForHR(num);
                }
                else
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
                }
            }
            else
            {
                managementObject = ManagementObject.GetManagementObject(wbemClassObjectFreeThreaded, base.Scope);
            }
            return(managementObject);
        }
 internal static ManagementBaseObject GetBaseObject(IWbemClassObjectFreeThreaded wbemObject, ManagementScope scope)
 {
     if (_IsClass(wbemObject))
     {
         return(ManagementClass.GetManagementClass(wbemObject, scope));
     }
     return(ManagementObject.GetManagementObject(wbemObject, scope));
 }
Esempio n. 3
0
        internal static ManagementBaseObject GetBaseObject(IWbemClassObjectFreeThreaded wbemObject, ManagementScope scope)
        {
            ManagementBaseObject managementObject;

            if (!ManagementBaseObject._IsClass(wbemObject))
            {
                managementObject = ManagementObject.GetManagementObject(wbemObject, scope);
            }
            else
            {
                managementObject = ManagementClass.GetManagementClass(wbemObject, scope);
            }
            return(managementObject);
        }
        // Factory
        /// <summary>
        /// Factory for various types of base object
        /// </summary>
        /// <param name="wbemObject"> IWbemClassObject </param>
        /// <param name="scope"> The scope</param>
        internal static ManagementBaseObject GetBaseObject(
            IWbemClassObjectFreeThreaded wbemObject,
            ManagementScope scope)
        {
            ManagementBaseObject newObject = null;

            if (_IsClass(wbemObject))
            {
                newObject = ManagementClass.GetManagementClass(wbemObject, scope);
            }
            else
            {
                newObject = ManagementObject.GetManagementObject(wbemObject, scope);
            }

            return(newObject);
        }
Esempio n. 5
0
        public ManagementObject CreateInstance()
        {
            ManagementObject obj2 = null;

            if (base.PutButNotGot)
            {
                base.Get();
                base.PutButNotGot = false;
            }
            IWbemClassObjectFreeThreaded ppNewInstance = null;
            int errorCode = base.wbemObject.SpawnInstance_(0, out ppNewInstance);

            if (errorCode >= 0)
            {
                return(ManagementObject.GetManagementObject(ppNewInstance, base.Scope));
            }
            if ((errorCode & 0xfffff000L) == 0x80041000L)
            {
                ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode);
                return(obj2);
            }
            Marshal.ThrowExceptionForHR(errorCode);
            return(obj2);
        }