Пример #1
0
        public override Collection <PSObject> Invoke(IEnumerable input)
        {
            // TODO: run the pipeline on another thread and wait for the completion

            Input.Write(input, true);

            SetPipelineState(PipelineState.NotStarted);

            ExecutionContext context = _runspace.ExecutionContext.Clone();

            RerouteExecutionContext(context);

            PipelineProcessor processor = new PipelineProcessor();

            // TODO: implement script execution
            foreach (Command command in Commands)
            {
                if (string.IsNullOrEmpty(command.CommandText))
                {
                    continue;
                }

                CommandProcessorBase commandProcessor = command.CreateCommandProcessor(context, _runspace.CommandManager, false);
                commandProcessor.Initialize();
                processor.Add(commandProcessor);
            }

            // TODO: add a default out-command to the pipeline
            // TODO: it should do the "foreach read from pipe and out via formatter"

            SetPipelineState(PipelineState.Running);
            try
            {
                processor.Execute(context);
                SetPipelineState(PipelineState.Completed);
            }
            catch (Exception ex)
            {
                SetPipelineState(PipelineState.Failed, ex);

                ((LocalRunspace)_runspace).PSHost.UI.WriteErrorLine(ex.Message);
            }

            // TODO: process Error results

            return(Output.NonBlockingRead());
        }
Пример #2
0
 internal void SetMergeResultOptions(CommandProcessorBase procBase)
 {
     var rt = procBase.CommandRuntime;
     rt.MergeErrorToOutput = (MergeMyResult.Equals(PipelineResultTypes.Error) &&
         MergeToResult.Equals(PipelineResultTypes.Output));
     rt.MergeUnclaimedPreviousErrors = MergeUnclaimedPreviousCommandResults != PipelineResultTypes.None;
 }
Пример #3
0
 public void Add(CommandProcessorBase commandProcessor)
 {
     commandsToExecute.Add(commandProcessor);
 }