private static void AddParameter(string parameterName, List <Token> parameterTokens, CommandParameterCollection parameters)
        {
            if (string.IsNullOrWhiteSpace(parameterName))
            {
                return;
            }
            if (parameterTokens == null || parameterTokens.Count == 0)
            {
                parameters.Add(new CommandParameter(parameterName));
                return;
            }
            int    i   = 0;
            object obj = null;

            i = CmdletValidator.GetParameterValue(parameterTokens, i, out obj);
            if (obj != null && i >= parameterTokens.Count)
            {
                parameters.Add(new CommandParameter(parameterName, obj));
                return;
            }
            List <object> list = new List <object>();

            if (obj != null)
            {
                list.Add(obj);
            }
            while (i < parameterTokens.Count)
            {
                i = CmdletValidator.GetParameterValue(parameterTokens, i, out obj);
                if (obj != null)
                {
                    list.Add(obj);
                }
            }
            parameters.Add(new CommandParameter(parameterName, list.ToArray()));
        }
        private static int GetParameterValue(List <Token> parameterValueTokens, int tokenIndex, out object parameterValue)
        {
            int count = parameterValueTokens.Count;

            parameterValue = null;
            if (tokenIndex >= count)
            {
                return(tokenIndex);
            }
            Token     token = parameterValueTokens[tokenIndex];
            TokenKind kind  = token.Kind;

            if (kind <= TokenKind.Number)
            {
                if (kind != TokenKind.Variable)
                {
                    if (kind == TokenKind.Number)
                    {
                        parameterValue = ((NumberToken)token).Value;
                        goto IL_23B;
                    }
                }
                else
                {
                    bool flag;
                    if (bool.TryParse(((VariableToken)token).Name, out flag))
                    {
                        parameterValue = flag;
                        goto IL_23B;
                    }
                    parameterValue = token.Text;
                    goto IL_23B;
                }
            }
            else
            {
                switch (kind)
                {
                case TokenKind.StringLiteral:
                    parameterValue = ((StringToken)token).Value;
                    goto IL_23B;

                case TokenKind.StringExpandable:
                    parameterValue = ((StringExpandableToken)token).Value;
                    goto IL_23B;

                default:
                    switch (kind)
                    {
                    case TokenKind.LBracket:
                    case TokenKind.RBracket:
                    case TokenKind.Comma:
                        parameterValue = null;
                        goto IL_23B;

                    case TokenKind.AtParen:
                    {
                        List <object> list = new List <object>();
                        tokenIndex++;
                        while (tokenIndex < count && parameterValueTokens[tokenIndex].Kind != TokenKind.RParen)
                        {
                            if (parameterValueTokens[tokenIndex].Kind == TokenKind.Comma)
                            {
                                tokenIndex++;
                            }
                            else
                            {
                                object obj = null;
                                tokenIndex = CmdletValidator.GetParameterValue(parameterValueTokens, tokenIndex, out obj);
                                if (obj != null)
                                {
                                    list.Add(obj);
                                }
                            }
                        }
                        parameterValue = list.ToArray();
                        goto IL_23B;
                    }

                    case TokenKind.AtCurly:
                    {
                        Dictionary <object, object> dictionary = new Dictionary <object, object>();
                        tokenIndex++;
                        while (tokenIndex < count && parameterValueTokens[tokenIndex].Kind != TokenKind.RCurly)
                        {
                            if (parameterValueTokens[tokenIndex].Kind == TokenKind.Semi)
                            {
                                tokenIndex++;
                            }
                            else
                            {
                                object obj2 = null;
                                tokenIndex = CmdletValidator.GetParameterValue(parameterValueTokens, tokenIndex, out obj2);
                                if (tokenIndex >= count || parameterValueTokens[tokenIndex].Kind != TokenKind.Equals)
                                {
                                    throw new InvalidOperationException(string.Format("Cmdlet parsing failed at index {0}. Expected Equals. Actual {1}", tokenIndex, parameterValueTokens[tokenIndex].Text));
                                }
                                if (++tokenIndex >= count)
                                {
                                    throw new InvalidOperationException(string.Format("Cmdlet parsing failed. No value for key {0}", obj2));
                                }
                                object value = null;
                                tokenIndex = CmdletValidator.GetParameterValue(parameterValueTokens, tokenIndex, out value);
                                dictionary.Add(obj2, value);
                            }
                        }
                        parameterValue = dictionary;
                        goto IL_23B;
                    }

                    case TokenKind.Semi:
                    case TokenKind.Pipe:
                        throw new InvalidOperationException(string.Format("Cmdlet parsing failed at index {0}. Encountered unexpected {1}", tokenIndex, token.Kind));
                    }
                    break;
                }
            }
            parameterValue = token.Text;
IL_23B:
            return(++tokenIndex);
        }