示例#1
0
        /// <summary>
        /// Creates a command processor for "get-help [helpTarget]"
        /// </summary>
        /// <param name="context">context for the command processor</param>
        /// <param name="helpTarget">help target</param>
        /// <param name="helpCategory">help category</param>
        /// <returns>command processor for "get-help [helpTarget]"</returns>
        internal static CommandProcessorBase CreateGetHelpCommandProcessor(
            ExecutionContext context,
            string helpTarget,
            HelpCategory helpCategory)
        {
            if (context == null)
            {
                throw PSTraceSource.NewArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(helpTarget))
            {
                throw PSTraceSource.NewArgumentNullException("helpTarget");
            }

            CommandProcessorBase helpCommandProcessor = context.CreateCommand("get-help", false);
            var cpi = CommandParameterInternal.CreateParameterWithArgument(
                /*parameterAst*/ null, "Name", "-Name:",
                /*argumentAst*/ null, helpTarget,
                false);

            helpCommandProcessor.AddParameter(cpi);
            cpi = CommandParameterInternal.CreateParameterWithArgument(
                /*parameterAst*/ null, "Category", "-Category:",
                /*argumentAst*/ null, helpCategory.ToString(),
                false);
            helpCommandProcessor.AddParameter(cpi);
            return(helpCommandProcessor);
        }
示例#2
0
        /// <summary>
        /// Creates a command processor for "get-help [helpTarget]"
        /// </summary>
        /// <param name="context">context for the command processor</param>
        /// <param name="helpTarget">help target</param>
        /// <param name="helpCategory">help category</param>
        /// <returns>command processor for "get-help [helpTarget]"</returns>
        internal static CommandProcessorBase CreateGetHelpCommandProcessor(
            ExecutionContext context,
            string helpTarget,
            HelpCategory helpCategory)
        {
            if (context == null)
            {
                throw PSTraceSource.NewArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(helpTarget))
            {
                throw PSTraceSource.NewArgumentNullException("helpTarget");
            }

            CommandProcessorBase helpCommandProcessor = context.CreateCommand("get-help", false);
            var cpi = CommandParameterInternal.CreateParameterWithArgument(
                PositionUtilities.EmptyExtent, "Name", "-Name:",
                PositionUtilities.EmptyExtent, helpTarget,
                false);
            helpCommandProcessor.AddParameter(cpi);
            cpi = CommandParameterInternal.CreateParameterWithArgument(
                PositionUtilities.EmptyExtent, "Category", "-Category:",
                PositionUtilities.EmptyExtent, helpCategory.ToString(),
                false);
            helpCommandProcessor.AddParameter(cpi);
            return helpCommandProcessor;
        }
示例#3
0
        internal static CommandProcessorBase CreateGetHelpCommandProcessor(ExecutionContext context, string helpTarget, HelpCategory helpCategory)
        {
            if (context == null)
            {
                throw PSTraceSource.NewArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(helpTarget))
            {
                throw PSTraceSource.NewArgumentNullException("helpTarget");
            }
            CommandProcessorBase     base2     = context.CreateCommand("get-help", false);
            CommandParameterInternal parameter = CommandParameterInternal.CreateParameterWithArgument(PositionUtilities.EmptyExtent, "Name", "-Name:", PositionUtilities.EmptyExtent, helpTarget, false);

            base2.AddParameter(parameter);
            parameter = CommandParameterInternal.CreateParameterWithArgument(PositionUtilities.EmptyExtent, "Category", "-Category:", PositionUtilities.EmptyExtent, helpCategory.ToString(), false);
            base2.AddParameter(parameter);
            return(base2);
        }