예제 #1
0
        private CimGetInstance CreateOperationAgent()
        {
            CimGetInstance cimGetInstance = new CimGetInstance();

            base.AsyncOperation = cimGetInstance;
            return(cimGetInstance);
        }
예제 #2
0
        /// <summary>
        /// <para>
        /// Create <see cref="CimGetInstance"/> object, which is
        /// used to delegate all Get-CimInstance operations, such
        /// as enumerate instances, get instance, query instance.
        /// </para>
        /// </summary>
        /// <returns></returns>
        CimGetInstance CreateOperationAgent()
        {
            CimGetInstance cimGetInstance = new CimGetInstance();

            this.AsyncOperation = cimGetInstance;
            return(cimGetInstance);
        }
예제 #3
0
        /// <summary>
        /// EndProcessing method.
        /// </summary>
        protected override void EndProcessing()
        {
            CimGetInstance cimGetInstance = this.GetOperationAgent();

            if (cimGetInstance != null)
            {
                cimGetInstance.ProcessRemainActions(this.CmdletOperation);
            }
        }
예제 #4
0
        /// <summary>
        /// ProcessRecord method.
        /// </summary>
        protected override void ProcessRecord()
        {
            base.CheckParameterSet();
            this.CheckArgument();
            CimGetInstance cimGetInstance = this.GetOperationAgent() ?? CreateOperationAgent();

            cimGetInstance.GetCimInstance(this);
            cimGetInstance.ProcessActions(this.CmdletOperation);
        }
예제 #5
0
        protected override void ProcessRecord()
        {
            base.CheckParameterSet();
            this.CheckArgument();
            CimGetInstance operationAgent = this.GetOperationAgent();

            if (operationAgent == null)
            {
                operationAgent = this.CreateOperationAgent();
            }
            operationAgent.GetCimInstance(this);
            operationAgent.ProcessActions(this.CmdletOperation);
        }
예제 #6
0
 /// <summary>
 /// <para>
 /// Create <see cref="CimGetInstance"/> object, which is
 /// used to delegate all Get-CimInstance operations, such
 /// as enumerate instances, get instance, query instance.
 /// </para>
 /// </summary>
 /// <returns></returns>
 CimGetInstance CreateOperationAgent()
 {
     CimGetInstance cimGetInstance = new CimGetInstance();
     this.AsyncOperation = cimGetInstance;
     return cimGetInstance;
 }
예제 #7
0
        public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet)
        {
            string @namespace;

            DebugHelper.WriteLogEx();
            IEnumerable <string>   computerNames     = ConstValue.GetComputerNames(CimGetInstance.GetComputerName(cmdlet));
            List <CimSessionProxy> cimSessionProxies = new List <CimSessionProxy>();
            string parameterSetName = cmdlet.ParameterSetName;
            string str = parameterSetName;

            if (parameterSetName != null)
            {
                if (str == "CimInstanceComputerSet")
                {
                    foreach (string computerName in computerNames)
                    {
                        cimSessionProxies.Add(base.CreateSessionProxy(computerName, cmdlet.CimInstance, cmdlet));
                    }
                }
                else
                {
                    if (str == "CimInstanceSessionSet")
                    {
                        CimSession[] cimSession = CimGetInstance.GetCimSession(cmdlet);
                        for (int i = 0; i < (int)cimSession.Length; i++)
                        {
                            CimSession cimSession1 = cimSession[i];
                            cimSessionProxies.Add(base.CreateSessionProxy(cimSession1, cmdlet));
                        }
                    }
                }
            }
            string parameterSetName1 = cmdlet.ParameterSetName;
            string str1 = parameterSetName1;

            if (parameterSetName1 != null)
            {
                if (str1 == "CimInstanceComputerSet" || str1 == "CimInstanceSessionSet")
                {
                    if (cmdlet.ResourceUri == null)
                    {
                        @namespace = ConstValue.GetNamespace(CimGetInstance.GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace);
                    }
                    else
                    {
                        @namespace = CimGetInstance.GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace;
                    }
                    string str2 = cmdlet.CimInstance.ToString();
                    foreach (CimSessionProxy cimSessionProxy in cimSessionProxies)
                    {
                        if (cmdlet.ShouldProcess(str2, "Remove-CimInstance"))
                        {
                            cimSessionProxy.DeleteInstanceAsync(@namespace, cmdlet.CimInstance);
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (str1 == "QueryComputerSet" || str1 == "QuerySessionSet")
                    {
                        base.GetCimInstanceInternal(cmdlet);
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
예제 #8
0
        public void SetCimInstance(SetCimInstanceCommand cmdlet)
        {
            IEnumerable <string>   computerNames     = ConstValue.GetComputerNames(CimGetInstance.GetComputerName(cmdlet));
            List <CimSessionProxy> cimSessionProxies = new List <CimSessionProxy>();
            string parameterSetName = cmdlet.ParameterSetName;
            string str = parameterSetName;

            if (parameterSetName != null)
            {
                if (str == "CimInstanceComputerSet")
                {
                    foreach (string computerName in computerNames)
                    {
                        cimSessionProxies.Add(base.CreateSessionProxy(computerName, cmdlet.CimInstance, cmdlet, cmdlet.PassThru));
                    }
                }
                else
                {
                    if (str == "CimInstanceSessionSet")
                    {
                        CimSession[] cimSession = CimGetInstance.GetCimSession(cmdlet);
                        for (int i = 0; i < (int)cimSession.Length; i++)
                        {
                            CimSession cimSession1 = cimSession[i];
                            cimSessionProxies.Add(base.CreateSessionProxy(cimSession1, cmdlet, cmdlet.PassThru));
                        }
                    }
                }
            }
            string parameterSetName1 = cmdlet.ParameterSetName;
            string str1 = parameterSetName1;

            if (parameterSetName1 != null)
            {
                if (str1 == "CimInstanceComputerSet" || str1 == "CimInstanceSessionSet")
                {
                    string @namespace = ConstValue.GetNamespace(CimGetInstance.GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace);
                    string str2       = cmdlet.CimInstance.ToString();
                    foreach (CimSessionProxy cimSessionProxy in cimSessionProxies)
                    {
                        if (cmdlet.ShouldProcess(str2, "Set-CimInstance"))
                        {
                            Exception   exception   = null;
                            CimInstance cimInstance = cmdlet.CimInstance;
                            if (cmdlet.Property == null || this.SetProperty(cmdlet.Property, ref cimInstance, ref exception))
                            {
                                cimSessionProxy.ModifyInstanceAsync(@namespace, cimInstance);
                            }
                            else
                            {
                                cmdlet.ThrowTerminatingError(exception, "Set-CimInstance");
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (str1 == "QueryComputerSet" || str1 == "QuerySessionSet")
                    {
                        base.GetCimInstanceInternal(cmdlet);
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
예제 #9
0
		private CimGetInstance CreateOperationAgent()
		{
			CimGetInstance cimGetInstance = new CimGetInstance();
			base.AsyncOperation = cimGetInstance;
			return cimGetInstance;
		}
예제 #10
0
        protected void GetCimInstanceInternal(CimBaseCommand cmdlet)
        {
            string @namespace;
            IEnumerable <string>   computerNames     = ConstValue.GetComputerNames(CimGetInstance.GetComputerName(cmdlet));
            List <CimSessionProxy> cimSessionProxies = new List <CimSessionProxy>();
            bool   flag             = cmdlet is GetCimInstanceCommand;
            string parameterSetName = cmdlet.ParameterSetName;
            string str = parameterSetName;

            if (parameterSetName != null)
            {
                switch (str)
                {
                case "CimInstanceComputerSet":
                {
                    IEnumerator <string> enumerator = computerNames.GetEnumerator();
                    using (enumerator)
                    {
                        while (enumerator.MoveNext())
                        {
                            string          current = enumerator.Current;
                            CimInstance     cimInstanceParameter = CimGetInstance.GetCimInstanceParameter(cmdlet);
                            CimSessionProxy cimSessionProxy      = this.CreateSessionProxy(current, cimInstanceParameter, cmdlet);
                            if (flag)
                            {
                                this.SetPreProcess(cimSessionProxy, cmdlet as GetCimInstanceCommand);
                            }
                            cimSessionProxies.Add(cimSessionProxy);
                        }
                    }
                }
                break;

                case "ClassNameComputerSet":
                case "QueryComputerSet":
                case "ResourceUriComputerSet":
                {
                    IEnumerator <string> enumerator1 = computerNames.GetEnumerator();
                    using (enumerator1)
                    {
                        while (enumerator1.MoveNext())
                        {
                            string          current1         = enumerator1.Current;
                            CimSessionProxy cimSessionProxy1 = this.CreateSessionProxy(current1, cmdlet);
                            if (flag)
                            {
                                this.SetPreProcess(cimSessionProxy1, cmdlet as GetCimInstanceCommand);
                            }
                            cimSessionProxies.Add(cimSessionProxy1);
                        }
                        break;
                    }
                }

                case "ClassNameSessionSet":
                case "CimInstanceSessionSet":
                case "QuerySessionSet":
                case "ResourceUriSessionSet":
                {
                    CimSession[] cimSession = CimGetInstance.GetCimSession(cmdlet);
                    for (int i = 0; i < (int)cimSession.Length; i++)
                    {
                        CimSession      cimSession1      = cimSession[i];
                        CimSessionProxy cimSessionProxy2 = this.CreateSessionProxy(cimSession1, cmdlet);
                        if (flag)
                        {
                            this.SetPreProcess(cimSessionProxy2, cmdlet as GetCimInstanceCommand);
                        }
                        cimSessionProxies.Add(cimSessionProxy2);
                    }
                }
                break;
                }
            }
            string parameterSetName1 = cmdlet.ParameterSetName;
            string str1 = parameterSetName1;

            if (parameterSetName1 != null)
            {
                if (str1 == "ClassNameComputerSet" || str1 == "ClassNameSessionSet")
                {
                    @namespace = ConstValue.GetNamespace(CimGetInstance.GetNamespace(cmdlet));
                    if (!CimGetInstance.IsClassNameQuerySet(cmdlet))
                    {
                        List <CimSessionProxy> .Enumerator enumerator2 = cimSessionProxies.GetEnumerator();
                        try
                        {
                            while (enumerator2.MoveNext())
                            {
                                CimSessionProxy current2 = enumerator2.Current;
                                current2.EnumerateInstancesAsync(@namespace, CimGetInstance.GetClassName(cmdlet));
                            }
                            return;
                        }
                        finally
                        {
                            enumerator2.Dispose();
                        }
                    }
                    else
                    {
                        string   str2     = CimGetInstance.CreateQuery(cmdlet);
                        object[] objArray = new object[1];
                        objArray[0] = str2;
                        DebugHelper.WriteLogEx("Query = {0}", 1, objArray);
                        List <CimSessionProxy> .Enumerator enumerator3 = cimSessionProxies.GetEnumerator();
                        try
                        {
                            while (enumerator3.MoveNext())
                            {
                                CimSessionProxy current3 = enumerator3.Current;
                                current3.QueryInstancesAsync(@namespace, ConstValue.GetQueryDialectWithDefault(CimGetInstance.GetQueryDialect(cmdlet)), str2);
                            }
                            return;
                        }
                        finally
                        {
                            enumerator3.Dispose();
                        }
                    }
                }
                else if (str1 == "CimInstanceComputerSet" || str1 == "CimInstanceSessionSet")
                {
                    CimInstance cimInstance = CimGetInstance.GetCimInstanceParameter(cmdlet);
                    @namespace = ConstValue.GetNamespace(cimInstance.CimSystemProperties.Namespace);
                    List <CimSessionProxy> .Enumerator enumerator4 = cimSessionProxies.GetEnumerator();
                    try
                    {
                        while (enumerator4.MoveNext())
                        {
                            CimSessionProxy cimSessionProxy3 = enumerator4.Current;
                            cimSessionProxy3.GetInstanceAsync(@namespace, cimInstance);
                        }
                        return;
                    }
                    finally
                    {
                        enumerator4.Dispose();
                    }
                }
                else if (str1 == "QueryComputerSet" || str1 == "QuerySessionSet")
                {
                    @namespace = ConstValue.GetNamespace(CimGetInstance.GetNamespace(cmdlet));
                    List <CimSessionProxy> .Enumerator enumerator5 = cimSessionProxies.GetEnumerator();
                    try
                    {
                        while (enumerator5.MoveNext())
                        {
                            CimSessionProxy current4 = enumerator5.Current;
                            current4.QueryInstancesAsync(@namespace, ConstValue.GetQueryDialectWithDefault(CimGetInstance.GetQueryDialect(cmdlet)), CimGetInstance.GetQuery(cmdlet));
                        }
                        return;
                    }
                    finally
                    {
                        enumerator5.Dispose();
                    }
                }
                else if (str1 == "ResourceUriSessionSet" || str1 == "ResourceUriComputerSet")
                {
                    List <CimSessionProxy> .Enumerator enumerator6 = cimSessionProxies.GetEnumerator();
                    try
                    {
                        while (enumerator6.MoveNext())
                        {
                            CimSessionProxy cimSessionProxy4 = enumerator6.Current;
                            cimSessionProxy4.EnumerateInstancesAsync(CimGetInstance.GetNamespace(cmdlet), CimGetInstance.GetClassName(cmdlet));
                        }
                        return;
                    }
                    finally
                    {
                        enumerator6.Dispose();
                    }
                }
                return;
            }
        }