Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
            }
        }