Пример #1
0
        /// <summary>
        /// <para>
        /// Base on parametersetName to retrieve <see cref="CimClass"/>
        /// </para>
        /// </summary>
        /// <param name="cmdlet"><see cref="GetCimClassCommand"/> object.</param>
        public void GetCimClass(GetCimClassCommand cmdlet)
        {
            List <CimSessionProxy> proxys = new List <CimSessionProxy>();
            string nameSpace = ConstValue.GetNamespace(cmdlet.Namespace);
            string className = (cmdlet.ClassName == null) ? @"*" : cmdlet.ClassName;
            CimGetCimClassContext context = new CimGetCimClassContext(
                cmdlet.ClassName,
                cmdlet.MethodName,
                cmdlet.PropertyName,
                cmdlet.QualifierName);

            switch (cmdlet.ParameterSetName)
            {
            case CimBaseCommand.ComputerSetName:
            {
                IEnumerable <string> computerNames = ConstValue.GetComputerNames(
                    cmdlet.ComputerName);
                foreach (string computerName in computerNames)
                {
                    CimSessionProxy proxy = CreateSessionProxy(computerName, cmdlet);
                    proxy.ContextObject = context;
                    proxys.Add(proxy);
                }
            }

            break;

            case CimBaseCommand.SessionSetName:
            {
                foreach (CimSession session in cmdlet.CimSession)
                {
                    CimSessionProxy proxy = CreateSessionProxy(session, cmdlet);
                    proxy.ContextObject = context;
                    proxys.Add(proxy);
                }
            }

            break;

            default:
                return;
            }

            if (WildcardPattern.ContainsWildcardCharacters(className))
            {
                // retrieve all classes and then filter based on
                // classname, propertyname, methodname, and qualifiername
                foreach (CimSessionProxy proxy in proxys)
                {
                    proxy.EnumerateClassesAsync(nameSpace);
                }
            }
            else
            {
                foreach (CimSessionProxy proxy in proxys)
                {
                    proxy.GetClassAsync(nameSpace, className);
                }
            }
        }
Пример #2
0
		private CimSessionProxy CreateSessionProxy(CimSession session, GetCimClassCommand cmdlet)
		{
			CimSessionProxy cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(session);
			base.SubscribeEventAndAddProxytoCache(cimSessionProxyGetCimClass);
			this.SetSessionProxyProperties(ref cimSessionProxyGetCimClass, cmdlet);
			return cimSessionProxyGetCimClass;
		}
Пример #3
0
        private CimSessionProxy CreateSessionProxy(string computerName, GetCimClassCommand cmdlet)
        {
            CimSessionProxy cimSessionProxyGetCimClass = null;

            if (!string.IsNullOrEmpty(computerName) && !computerName.Equals("localhost", StringComparison.OrdinalIgnoreCase))
            {
                /* Set on the fly credentials */
                System.Management.Automation.PSCredential credential = GetOnTheFlyCredentials(cmdlet);
                if (credential == null)
                {
                    cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(computerName);
                }
                else
                {
                    CimSessionOptions options = new WSManSessionOptions();
                    options.AddDestinationCredentials(cmdlet.CreateCimCredentials(credential, PasswordAuthenticationMechanism.Default, "Get-CimClass", "Authentication"));
                    cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(computerName, options);
                }
            }
            else
            {
                cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(computerName);
            }
            base.SubscribeEventAndAddProxytoCache(cimSessionProxyGetCimClass);
            this.SetSessionProxyProperties(ref cimSessionProxyGetCimClass, cmdlet);
            return(cimSessionProxyGetCimClass);
        }
Пример #4
0
 /// <summary>
 /// <para>
 /// Set <see cref="CimSessionProxy"/> properties
 /// </para>
 /// </summary>
 /// <param name="proxy"></param>
 /// <param name="cmdlet"></param>
 private static void SetSessionProxyProperties(
     ref CimSessionProxy proxy,
     GetCimClassCommand cmdlet)
 {
     proxy.OperationTimeout = cmdlet.OperationTimeoutSec;
     proxy.Amended          = cmdlet.Amended;
 }
Пример #5
0
        private CimSessionProxy CreateSessionProxy(CimSession session, GetCimClassCommand cmdlet)
        {
            CimSessionProxy cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(session);

            base.SubscribeEventAndAddProxytoCache(cimSessionProxyGetCimClass);
            this.SetSessionProxyProperties(ref cimSessionProxyGetCimClass, cmdlet);
            return(cimSessionProxyGetCimClass);
        }
Пример #6
0
        /// <summary>
        /// Create <see cref="CimSessionProxy"/> and set properties.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="cmdlet"></param>
        /// <returns></returns>
        private CimSessionProxy CreateSessionProxy(
            CimSession session,
            GetCimClassCommand cmdlet)
        {
            CimSessionProxy proxy = new CimSessionProxyGetCimClass(session);

            this.SubscribeEventAndAddProxytoCache(proxy);
            SetSessionProxyProperties(ref proxy, cmdlet);
            return(proxy);
        }
Пример #7
0
        /// <summary>
        /// <para>
        /// Create <see cref="CimSessionProxy"/> and set properties
        /// </para>
        /// </summary>
        /// <param name="computerName"></param>
        /// <param name="cmdlet"></param>
        /// <returns></returns>
        private CimSessionProxy CreateSessionProxy(
            string computerName,
            GetCimClassCommand cmdlet)
        {
            CimSessionProxy proxy = new CimSessionProxyGetCimClass(computerName);

            this.SubscribeEventAndAddProxytoCache(proxy);
            SetSessionProxyProperties(ref proxy, cmdlet);
            return(proxy);
        }
Пример #8
0
		private CimSessionProxy CreateSessionProxy(string computerName, GetCimClassCommand cmdlet)
		{
			CimSessionProxy cimSessionProxyGetCimClass = null;
			if (!string.IsNullOrEmpty (computerName) && !computerName.Equals ("localhost", StringComparison.OrdinalIgnoreCase)) {
				/* Set on the fly credentials */
				System.Management.Automation.PSCredential credential = GetOnTheFlyCredentials(cmdlet);
				if (credential == null) 
					cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(computerName);
				else {
					CimSessionOptions options = new WSManSessionOptions ();
					options.AddDestinationCredentials (cmdlet.CreateCimCredentials (credential, PasswordAuthenticationMechanism.Default, "Get-CimClass", "Authentication"));
					cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass (computerName, options);
				}
			}
			else {
				cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(computerName);
			}
			base.SubscribeEventAndAddProxytoCache(cimSessionProxyGetCimClass);
			this.SetSessionProxyProperties(ref cimSessionProxyGetCimClass, cmdlet);
			return cimSessionProxyGetCimClass;
		}
Пример #9
0
 /// <summary>
 /// <para>
 /// Set <see cref="CimSessionProxy"/> properties
 /// </para>
 /// </summary>
 /// <param name="proxy"></param>
 /// <param name="cmdlet"></param>
 private void SetSessionProxyProperties(
     ref CimSessionProxy proxy,
     GetCimClassCommand cmdlet)
 {
     proxy.OperationTimeout = cmdlet.OperationTimeoutSec;
 }
Пример #10
0
		public void GetCimClass(GetCimClassCommand cmdlet)
		{
			string className;
			List<CimSessionProxy> cimSessionProxies = new List<CimSessionProxy>();
			string @namespace = ConstValue.GetNamespace(cmdlet.Namespace);
			if (cmdlet.ClassName == null)
			{
				className = "*";
			}
			else
			{
				className = cmdlet.ClassName;
			}
			string str = className;
			CimGetCimClassContext cimGetCimClassContext = new CimGetCimClassContext(cmdlet.ClassName, cmdlet.MethodName, cmdlet.PropertyName, cmdlet.QualifierName);
			string parameterSetName = cmdlet.ParameterSetName;
			string str1 = parameterSetName;
			if (parameterSetName == null)
			{
				return;
			}
			else
			{
				if (str1 == "ComputerSet")
				{
					IEnumerable<string> computerNames = ConstValue.GetComputerNames(cmdlet.ComputerName);
					foreach (string computerName in computerNames)
					{
						CimSessionProxy cimSessionProxy = this.CreateSessionProxy(computerName, cmdlet);
						cimSessionProxy.ContextObject = cimGetCimClassContext;
						cimSessionProxies.Add(cimSessionProxy);
					}
				}
				else
				{
					if (str1 == "SessionSet")
					{
						CimSession[] cimSession = cmdlet.CimSession;
						for (int i = 0; i < (int)cimSession.Length; i++)
						{
							CimSession cimSession1 = cimSession[i];
							CimSessionProxy cimSessionProxy1 = this.CreateSessionProxy(cimSession1, cmdlet);
							cimSessionProxy1.ContextObject = cimGetCimClassContext;
							cimSessionProxies.Add(cimSessionProxy1);
						}
					}
					else
					{
						return;
					}
				}
				if (!WildcardPattern.ContainsWildcardCharacters(str))
				{
					foreach (CimSessionProxy cimSessionProxy2 in cimSessionProxies)
					{
						cimSessionProxy2.GetClassAsync(@namespace, str);
					}
				}
				else
				{
					foreach (CimSessionProxy cimSessionProxy3 in cimSessionProxies)
					{
						cimSessionProxy3.EnumerateClassesAsync(@namespace);
					}
				}
				return;
			}
		}
Пример #11
0
		private void SetSessionProxyProperties(ref CimSessionProxy proxy, GetCimClassCommand cmdlet)
		{
			proxy.OperationTimeout = cmdlet.OperationTimeoutSec;
		}
Пример #12
0
 /// <summary>
 /// Create <see cref="CimSessionProxy"/> and set properties
 /// </summary>
 /// <param name="session"></param>
 /// <param name="cmdlet"></param>
 /// <returns></returns>
 private CimSessionProxy CreateSessionProxy(
     CimSession session,
     GetCimClassCommand cmdlet)
 {
     CimSessionProxy proxy = new CimSessionProxyGetCimClass(session);
     this.SubscribeEventAndAddProxytoCache(proxy);
     SetSessionProxyProperties(ref proxy, cmdlet);
     return proxy;
 }
Пример #13
0
 /// <summary>
 /// <para>
 /// Create <see cref="CimSessionProxy"/> and set properties
 /// </para>
 /// </summary>
 /// <param name="computerName"></param>
 /// <param name="cmdlet"></param>
 /// <returns></returns>
 private CimSessionProxy CreateSessionProxy(
     string computerName,
     GetCimClassCommand cmdlet)
 {
     CimSessionProxy proxy = new CimSessionProxyGetCimClass(computerName);
     this.SubscribeEventAndAddProxytoCache(proxy);
     SetSessionProxyProperties(ref proxy, cmdlet);
     return proxy;
 }
Пример #14
0
        /// <summary>
        /// <para>
        /// Base on parametersetName to retrieve <see cref="CimClass"/>
        /// </para>
        /// </summary>
        /// <param name="cmdlet"><see cref="GetCimClassCommand"/> object</param>
        public void GetCimClass(GetCimClassCommand cmdlet)
        {
            List<CimSessionProxy> proxys = new List<CimSessionProxy>();
            string nameSpace = ConstValue.GetNamespace(cmdlet.Namespace);
            string className = (cmdlet.ClassName == null) ? @"*" : cmdlet.ClassName;
            CimGetCimClassContext context = new CimGetCimClassContext(
                cmdlet.ClassName,
                cmdlet.MethodName,
                cmdlet.PropertyName,
                cmdlet.QualifierName);
            switch (cmdlet.ParameterSetName)
            {
                case CimBaseCommand.ComputerSetName:
                    {
                        IEnumerable<string> computerNames = ConstValue.GetComputerNames(
                                cmdlet.ComputerName);
                        foreach (string computerName in computerNames)
                        {
                            CimSessionProxy proxy = CreateSessionProxy(computerName, cmdlet);
                            proxy.ContextObject = context;
                            proxys.Add(proxy);
                        }
                    }
                    break;
                case CimBaseCommand.SessionSetName:
                    {
                        foreach (CimSession session in cmdlet.CimSession)
                        {
                            CimSessionProxy proxy = CreateSessionProxy(session, cmdlet);
                            proxy.ContextObject = context;
                            proxys.Add(proxy);
                        }
                    }
                    break;
                default:
                    return;
            }

            if (WildcardPattern.ContainsWildcardCharacters(className))
            {
                // retrieve all classes and then filter based on
                // classname, propertyname, methodname, and qualifiername
                foreach (CimSessionProxy proxy in proxys)
                {
                    proxy.EnumerateClassesAsync(nameSpace);
                }
            }
            else
            {
                foreach (CimSessionProxy proxy in proxys)
                {
                    proxy.GetClassAsync(nameSpace, className);
                }
            }
        }
Пример #15
0
        public void GetCimClass(GetCimClassCommand cmdlet)
        {
            string className;
            List <CimSessionProxy> cimSessionProxies = new List <CimSessionProxy>();
            string @namespace = ConstValue.GetNamespace(cmdlet.Namespace);

            if (cmdlet.ClassName == null)
            {
                className = "*";
            }
            else
            {
                className = cmdlet.ClassName;
            }
            string str = className;
            CimGetCimClassContext cimGetCimClassContext = new CimGetCimClassContext(cmdlet.ClassName, cmdlet.MethodName, cmdlet.PropertyName, cmdlet.QualifierName);
            string parameterSetName = cmdlet.ParameterSetName;
            string str1             = parameterSetName;

            if (parameterSetName == null)
            {
                return;
            }
            else
            {
                if (str1 == "ComputerSet")
                {
                    IEnumerable <string> computerNames = ConstValue.GetComputerNames(cmdlet.ComputerName);
                    foreach (string computerName in computerNames)
                    {
                        CimSessionProxy cimSessionProxy = this.CreateSessionProxy(computerName, cmdlet);
                        cimSessionProxy.ContextObject = cimGetCimClassContext;
                        cimSessionProxies.Add(cimSessionProxy);
                    }
                }
                else
                {
                    if (str1 == "SessionSet")
                    {
                        CimSession[] cimSession = cmdlet.CimSession;
                        for (int i = 0; i < (int)cimSession.Length; i++)
                        {
                            CimSession      cimSession1      = cimSession[i];
                            CimSessionProxy cimSessionProxy1 = this.CreateSessionProxy(cimSession1, cmdlet);
                            cimSessionProxy1.ContextObject = cimGetCimClassContext;
                            cimSessionProxies.Add(cimSessionProxy1);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                if (!WildcardPattern.ContainsWildcardCharacters(str))
                {
                    foreach (CimSessionProxy cimSessionProxy2 in cimSessionProxies)
                    {
                        cimSessionProxy2.GetClassAsync(@namespace, str);
                    }
                }
                else
                {
                    foreach (CimSessionProxy cimSessionProxy3 in cimSessionProxies)
                    {
                        cimSessionProxy3.EnumerateClassesAsync(@namespace);
                    }
                }
                return;
            }
        }