System.Management.Pash.Implementation.ExecutionVisitor.ConvertCommandElementToCommandParameter C# (CSharp) Method

ConvertCommandElementToCommandParameter() private method

private ConvertCommandElementToCommandParameter ( System.Management.Automation.Language.CommandElementAst commandElement ) : System.Management.Automation.Runspaces.CommandParameter
commandElement System.Management.Automation.Language.CommandElementAst
return System.Management.Automation.Runspaces.CommandParameter
        CommandParameter ConvertCommandElementToCommandParameter(CommandElementAst commandElement)
        {
            if (commandElement is CommandParameterAst)
            {
                var commandParameterAst = commandElement as CommandParameterAst;
                object arg = commandParameterAst.Argument == null ? null : EvaluateAst(commandParameterAst.Argument);
                return new CommandParameter(commandParameterAst.ParameterName, arg,
                                            commandParameterAst.RequiresArgument);
            }

            else if (commandElement is StringConstantExpressionAst)
            {
                var stringConstantExpressionAst = commandElement as StringConstantExpressionAst;
                return new CommandParameter(null, stringConstantExpressionAst.Value);
            }

            else if (commandElement is ExpressionAst)
            {
                return new CommandParameter(null, EvaluateAst(commandElement));
            }

            else throw new NotImplementedException();
        }
ExecutionVisitor