コード例 #1
0
ファイル: CimGetCimClass.cs プロジェクト: A-mIn3/PowerShell-2
        /// <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
ファイル: CimGetCimClass.cs プロジェクト: nickchal/pash
		private CimSessionProxy CreateSessionProxy(CimSession session, GetCimClassCommand cmdlet)
		{
			CimSessionProxy cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(session);
			base.SubscribeEventAndAddProxytoCache(cimSessionProxyGetCimClass);
			this.SetSessionProxyProperties(ref cimSessionProxyGetCimClass, cmdlet);
			return cimSessionProxyGetCimClass;
		}
コード例 #3
0
ファイル: CimGetCimClass.cs プロジェクト: modulexcite/pash-1
        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
ファイル: CimGetCimClass.cs プロジェクト: modulexcite/pash-1
        private CimSessionProxy CreateSessionProxy(CimSession session, GetCimClassCommand cmdlet)
        {
            CimSessionProxy cimSessionProxyGetCimClass = new CimSessionProxyGetCimClass(session);

            base.SubscribeEventAndAddProxytoCache(cimSessionProxyGetCimClass);
            this.SetSessionProxyProperties(ref cimSessionProxyGetCimClass, cmdlet);
            return(cimSessionProxyGetCimClass);
        }
コード例 #6
0
ファイル: CimGetCimClass.cs プロジェクト: A-mIn3/PowerShell-2
        /// <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
ファイル: CimGetCimClass.cs プロジェクト: A-mIn3/PowerShell-2
        /// <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
ファイル: CimGetCimClass.cs プロジェクト: nickchal/pash
		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
ファイル: CimGetCimClass.cs プロジェクト: A-mIn3/PowerShell-2
 /// <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
ファイル: CimGetCimClass.cs プロジェクト: nickchal/pash
		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
ファイル: CimGetCimClass.cs プロジェクト: nickchal/pash
		private void SetSessionProxyProperties(ref CimSessionProxy proxy, GetCimClassCommand cmdlet)
		{
			proxy.OperationTimeout = cmdlet.OperationTimeoutSec;
		}
コード例 #12
0
ファイル: CimGetCimClass.cs プロジェクト: 40a/PowerShell
 /// <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
ファイル: CimGetCimClass.cs プロジェクト: 40a/PowerShell
 /// <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
ファイル: CimGetCimClass.cs プロジェクト: 40a/PowerShell
        /// <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
ファイル: CimGetCimClass.cs プロジェクト: modulexcite/pash-1
        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;
            }
        }