示例#1
0
        public CimInstance(CimClass cimClass)
        {
            InstanceHandle instanceHandle = null;

            this._CimSessionInstanceID = Guid.Empty;
            if (cimClass != null)
            {
                MiResult miResult = ApplicationMethods.NewInstance(CimApplication.Handle, cimClass.CimSystemProperties.ClassName, cimClass.ClassHandle, out instanceHandle);
                if (miResult != MiResult.INVALID_PARAMETER)
                {
                    CimException.ThrowIfMiResultFailure(miResult);
                    this._myHandle = new SharedInstanceHandle(instanceHandle);
                    miResult       = InstanceMethods.SetNamespace(this._myHandle.Handle, cimClass.CimSystemProperties.Namespace);
                    CimException.ThrowIfMiResultFailure(miResult);
                    miResult = InstanceMethods.SetServerName(this._myHandle.Handle, cimClass.CimSystemProperties.ServerName);
                    CimException.ThrowIfMiResultFailure(miResult);
                    return;
                }
                else
                {
                    throw new ArgumentOutOfRangeException("cimClass");
                }
            }
            else
            {
                throw new ArgumentNullException("cimClass");
            }
        }
示例#2
0
        public CimInstance(string className, string namespaceName)
        {
            InstanceHandle instanceHandle = null;

            this._CimSessionInstanceID = Guid.Empty;
            if (className != null)
            {
                MiResult miResult  = ApplicationMethods.NewInstance(CimApplication.Handle, className, null, out instanceHandle);
                MiResult miResult1 = miResult;
                if (miResult1 != MiResult.INVALID_PARAMETER)
                {
                    CimException.ThrowIfMiResultFailure(miResult);
                    this._myHandle = new SharedInstanceHandle(instanceHandle);
                    if (namespaceName != null)
                    {
                        miResult = InstanceMethods.SetNamespace(this._myHandle.Handle, namespaceName);
                        CimException.ThrowIfMiResultFailure(miResult);
                    }
                    return;
                }
                else
                {
                    throw new ArgumentOutOfRangeException("className");
                }
            }
            else
            {
                throw new ArgumentNullException("className");
            }
        }
示例#3
0
 public CimInstance(CimInstance cimInstanceToClone)
 {
     this._CimSessionInstanceID = Guid.Empty;
     if (cimInstanceToClone != null)
     {
         InstanceHandle instanceHandle = cimInstanceToClone.InstanceHandle.Clone();
         this._myHandle = new SharedInstanceHandle(instanceHandle);
         return;
     }
     else
     {
         throw new ArgumentNullException("cimInstanceToClone");
     }
 }
示例#4
0
 private CimInstance(SerializationInfo info, StreamingContext context)
 {
     this._CimSessionInstanceID = Guid.Empty;
     if (info != null)
     {
         string          str             = info.GetString("MI_XML");
         byte[]          bytes           = Encoding.Unicode.GetBytes(str);
         CimDeserializer cimDeserializer = CimDeserializer.Create();
         using (cimDeserializer)
         {
             int            num            = 0;
             InstanceHandle instanceHandle = cimDeserializer.DeserializeInstanceHandle(bytes, ref num, null);
             this._myHandle = new SharedInstanceHandle(instanceHandle);
         }
         this.SetCimSessionComputerName(info.GetString("CSCN"));
         return;
     }
     else
     {
         throw new ArgumentNullException("info");
     }
 }
 internal CimPropertiesCollection(SharedInstanceHandle instanceHandle, CimInstance instance)
 {
     this._instanceHandle = instanceHandle;
     this._instance       = instance;
 }
示例#6
0
 internal CimPropertyOfInstance(SharedInstanceHandle instanceHandle, CimInstance instance, int index)
 {
     this._instanceHandle = instanceHandle;
     this._instance       = instance;
     this._index          = index;
 }
示例#7
0
        internal static object ConvertFromNativeLayer(object value, SharedInstanceHandle sharedParentHandle = null, CimInstance parent = null, bool clone = false)
        {
            InstanceHandle instanceHandle;
            InstanceHandle instanceHandle1;
            InstanceHandle instanceHandle2 = value as InstanceHandle;

            if (instanceHandle2 == null)
            {
                InstanceHandle[] instanceHandleArray = value as InstanceHandle[];
                if (instanceHandleArray == null)
                {
                    return(value);
                }
                else
                {
                    CimInstance[] cimInstanceArray = new CimInstance[(int)instanceHandleArray.Length];
                    for (int i = 0; i < (int)instanceHandleArray.Length; i++)
                    {
                        InstanceHandle instanceHandle3 = instanceHandleArray[i];
                        if (instanceHandle3 != null)
                        {
                            CimInstance[] cimInstance = cimInstanceArray;
                            int           num         = i;
                            if (clone)
                            {
                                instanceHandle = instanceHandle3.Clone();
                            }
                            else
                            {
                                instanceHandle = instanceHandle3;
                            }
                            cimInstance[num] = new CimInstance(instanceHandle, sharedParentHandle);
                            if (parent != null)
                            {
                                cimInstanceArray[i].SetCimSessionComputerName(parent.GetCimSessionComputerName());
                                cimInstanceArray[i].SetCimSessionInstanceId(parent.GetCimSessionInstanceId());
                            }
                        }
                        else
                        {
                            cimInstanceArray[i] = null;
                        }
                    }
                    return(cimInstanceArray);
                }
            }
            else
            {
                if (clone)
                {
                    instanceHandle1 = instanceHandle2.Clone();
                }
                else
                {
                    instanceHandle1 = instanceHandle2;
                }
                CimInstance cimInstance1 = new CimInstance(instanceHandle1, sharedParentHandle);
                if (parent != null)
                {
                    cimInstance1.SetCimSessionComputerName(parent.GetCimSessionComputerName());
                    cimInstance1.SetCimSessionInstanceId(parent.GetCimSessionInstanceId());
                }
                return(cimInstance1);
            }
        }
示例#8
0
 internal CimInstance(InstanceHandle handle, SharedInstanceHandle parentHandle)
 {
     this._CimSessionInstanceID = Guid.Empty;
     this._myHandle             = new SharedInstanceHandle(handle, parentHandle);
 }