Exemple #1
0
        internal PSParameterInfo FindParameterInfo(string parameter)
        {
            IEnumerable <PSParameterSet> pSParameterSets = this.ParameterSets.FindAll((PSParameterSet item) => item.Parameters.ContainsKey(parameter));

            object[] cmdletName = new object[2];
            cmdletName[0] = parameter;
            cmdletName[1] = this.CmdletName;
            ExceptionHelpers.ThrowArgumentExceptionIf("parameter", pSParameterSets.Count <PSParameterSet>() == 0, Resources.ParameterNotFoundInCommand, cmdletName);
            PSParameterInfo pSParameterInfo = null;

            foreach (PSParameterSet pSParameterSet in pSParameterSets)
            {
                PSParameterInfo pSParameterInfo1 = pSParameterSet.Parameters[parameter];
                if (pSParameterInfo != null)
                {
                    if (!(pSParameterInfo.Type != pSParameterInfo1.Type) && pSParameterInfo.IsSwitch == pSParameterInfo1.IsSwitch)
                    {
                        continue;
                    }
                    TraceHelper.Current.DebugMessage(string.Concat("Parameter ", parameter, " is found in multiple parameter set and has either different Type or IsSwitch value. So FindParametersInfo returns null"));
                    pSParameterInfo = null;
                    break;
                }
                else
                {
                    pSParameterInfo = pSParameterInfo1;
                }
            }
            return(pSParameterInfo);
        }
Exemple #2
0
        internal string GetParameterType(string parameter, ulong parameterSetsBitmask)
        {
            if (this.IsAllParameterSet(parameterSetsBitmask))
            {
                PSParameterSet allParameterSet = this.GetAllParameterSet();
                if (allParameterSet != null)
                {
                    PSParameterInfo pSParameterInfo = null;
                    if (allParameterSet.Parameters.TryGetValue(parameter, out pSParameterInfo))
                    {
                        return(pSParameterInfo.Type);
                    }
                }
            }
            HashSet <string> parameterTypes = this.GetParameterTypes(parameter, parameterSetsBitmask);

            if (parameterTypes.Count != 1)
            {
                return(null);
            }
            else
            {
                return(parameterTypes.ElementAt <string>(0));
            }
        }
Exemple #3
0
        internal bool IsSwitch(string parameterName)
        {
            PSParameterInfo pSParameterInfo = this.FindParameterInfo(parameterName);

            if (pSParameterInfo == null)
            {
                return(false);
            }
            else
            {
                return(pSParameterInfo.IsSwitch);
            }
        }