示例#1
0
        /// <summary>
        /// shut down the pipeline
        /// </summary>
        /// <returns>Array of objects out of the success pipeline</returns>
        internal Array ShutDown()
        {
            if (_pp == null)
            {
                // if Process() never got called, no sub pipeline
                // ever got created, hence we just return an empty array
                return(new object[0]);
            }

            PipelineProcessor ppTemp = _pp;

            _pp = null;
            return(ppTemp.SynchronousExecuteEnumerate(AutomationNull.Value));
        }
示例#2
0
        internal static void InvokePipeline(object input, bool ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
        {
            PipelineProcessor pipelineProcessor = new PipelineProcessor();

            System.Management.Automation.ExecutionContext context = funcContext._executionContext;
            Pipe pipe = funcContext._outputPipe;

            try {
                if (context.Events != null)
                {
                    context.Events.ProcessPendingActions();
                }
                if ((input == AutomationNull.Value) && !ignoreInput)
                {
                    AddNoopCommandProcessor(pipelineProcessor, context);
                }
                CommandProcessorBase commandProcessor = null;
                CommandRedirection[] redirections     = null;
                for (int i = 0; i < pipeElements.Length; i++)
                {
                    redirections     = (commandRedirections != null) ? commandRedirections [i] : null;
                    commandProcessor = AddCommand(pipelineProcessor, pipeElements [i], pipeElementAsts [i], redirections, context);
                }
                if ((commandProcessor != null) && !commandProcessor.CommandRuntime.OutputPipe.IsRedirected)
                {
                    pipelineProcessor.LinkPipelineSuccessOutput(pipe ?? new Pipe(new ArrayList()));
                    if (redirections != null)
                    {
                        foreach (CommandRedirection redirection in redirections)
                        {
                            if (redirection is MergingRedirection)
                            {
                                redirection.Bind(pipelineProcessor, commandProcessor, context);
                            }
                        }
                    }
                }
                context.PushPipelineProcessor(pipelineProcessor);
                try {
                    pipelineProcessor.SynchronousExecuteEnumerate(input, null, true);
                } finally {
                    context.PopPipelineProcessor(false);
                }
            }
            finally
            {
                context.QuestionMarkVariableValue = !pipelineProcessor.ExecutionFailed;
                pipelineProcessor.Dispose();
            }
        }