Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 2
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;
			}
		}
Exemplo n.º 3
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);
                }
            }
        }
        protected override bool PreNewActionEvent(CmdletActionEventArgs args)
        {
            WildcardPattern wildcardPattern;

            DebugHelper.WriteLogEx();
            if (args.Action as CimWriteResultObject != null)
            {
                CimWriteResultObject action = args.Action as CimWriteResultObject;
                CimClass             result = action.Result as CimClass;
                if (result != null)
                {
                    object[] className = new object[1];
                    className[0] = result.CimSystemProperties.ClassName;
                    DebugHelper.WriteLog("class name = {0}", 1, className);
                    CimGetCimClassContext contextObject = base.ContextObject as CimGetCimClassContext;
                    if (WildcardPattern.ContainsWildcardCharacters(contextObject.ClassName))
                    {
                        wildcardPattern = new WildcardPattern(contextObject.ClassName, WildcardOptions.IgnoreCase);
                        if (!wildcardPattern.IsMatch(result.CimSystemProperties.ClassName))
                        {
                            return(false);
                        }
                    }
                    if (contextObject.PropertyName != null)
                    {
                        wildcardPattern = new WildcardPattern(contextObject.PropertyName, WildcardOptions.IgnoreCase);
                        bool flag = false;
                        if (result.CimClassProperties != null)
                        {
                            foreach (CimPropertyDeclaration cimClassProperty in result.CimClassProperties)
                            {
                                object[] name = new object[1];
                                name[0] = cimClassProperty.Name;
                                DebugHelper.WriteLog("--- property name : {0}", 1, name);
                                if (!wildcardPattern.IsMatch(cimClassProperty.Name))
                                {
                                    continue;
                                }
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            object[] propertyName = new object[1];
                            propertyName[0] = contextObject.PropertyName;
                            DebugHelper.WriteLog("Property name does not match: {0}", 1, propertyName);
                            return(flag);
                        }
                    }
                    if (contextObject.MethodName != null)
                    {
                        wildcardPattern = new WildcardPattern(contextObject.MethodName, WildcardOptions.IgnoreCase);
                        bool flag1 = false;
                        if (result.CimClassMethods != null)
                        {
                            foreach (CimMethodDeclaration cimClassMethod in result.CimClassMethods)
                            {
                                object[] objArray = new object[1];
                                objArray[0] = cimClassMethod.Name;
                                DebugHelper.WriteLog("--- method name : {0}", 1, objArray);
                                if (!wildcardPattern.IsMatch(cimClassMethod.Name))
                                {
                                    continue;
                                }
                                flag1 = true;
                                break;
                            }
                        }
                        if (!flag1)
                        {
                            object[] methodName = new object[1];
                            methodName[0] = contextObject.MethodName;
                            DebugHelper.WriteLog("Method name does not match: {0}", 1, methodName);
                            return(flag1);
                        }
                    }
                    if (contextObject.QualifierName != null)
                    {
                        wildcardPattern = new WildcardPattern(contextObject.QualifierName, WildcardOptions.IgnoreCase);
                        bool flag2 = false;
                        if (result.CimClassQualifiers != null)
                        {
                            foreach (CimQualifier cimClassQualifier in result.CimClassQualifiers)
                            {
                                object[] name1 = new object[1];
                                name1[0] = cimClassQualifier.Name;
                                DebugHelper.WriteLog("--- qualifier name : {0}", 1, name1);
                                if (!wildcardPattern.IsMatch(cimClassQualifier.Name))
                                {
                                    continue;
                                }
                                flag2 = true;
                                break;
                            }
                        }
                        if (!flag2)
                        {
                            object[] qualifierName = new object[1];
                            qualifierName[0] = contextObject.QualifierName;
                            DebugHelper.WriteLog("Qualifer name does not match: {0}", 1, qualifierName);
                            return(flag2);
                        }
                    }
                    object[] className1 = new object[1];
                    className1[0] = result.CimSystemProperties.ClassName;
                    DebugHelper.WriteLog("CimClass '{0}' is qulified.", 1, className1);
                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 5
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;
            }
        }