コード例 #1
0
 // TODO: hook the runtime to the Host for Debug and Error output
 internal PipelineCommandRuntime(PipelineProcessor pipelineProcessor)
 {
     PipelineProcessor = pipelineProcessor;
     MergeErrorToOutput = false;
     MergeUnclaimedPreviousErrors = false;
     OutputStream = new ObjectStream(this);
     ErrorStream = new ObjectStream(this);
     InputStream = new ObjectStream(this);
 }
コード例 #2
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());
        }
コード例 #3
0
ファイル: LocalPipeline.cs プロジェクト: anton-gogolev/Pash
        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 pipelineProcessor = BuildPipelineProcessor(context);

            if (pipelineProcessor == null)
            {
                return(null);
            }

            // 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
            {
                pipelineProcessor.Execute(context);
                SetPipelineState(PipelineState.Completed);
            }
            catch (Exception ex)
            {
                SetPipelineState(PipelineState.Failed, ex);

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

            // TODO: process Error results

            return(Output.NonBlockingRead());
        }
コード例 #4
0
        PipelineProcessor BuildPipelineProcessor(ExecutionContext context)
        {
            PipelineProcessor pipelineProcessor = new PipelineProcessor();

            // TODO: implement script execution
            foreach (Command command in Commands)
            {
                CommandProcessorBase commandProcessor;

                try
                {
                    commandProcessor = command.CreateCommandProcessor(context, _runspace.CommandManager, false);
                }
                catch (PowerShellGrammar.ParseException exception)
                {
                    // nicer error message
                    throw new ParseException("Parse error at " + exception.LogMessage.Location.ToUiString(), exception);
                }
                pipelineProcessor.Add(commandProcessor);
            }

            return(pipelineProcessor);
        }
コード例 #5
0
 // TODO: hook the runtime to the Host for Debug and Error output
 internal PipelineCommandRuntime(PipelineProcessor pipelineProcessor)
 {
     this.pipelineProcessor = pipelineProcessor;
     this.outputResults = new ObjectStream();
     this.errorResults = new ObjectStream();
 }
コード例 #6
0
 internal void SetPipelineProcessor(PipelineProcessor pipelineProcessor)
 {
     CommandRuntime.PipelineProcessor = pipelineProcessor;
 }
コード例 #7
0
ファイル: CommandProcessorBase.cs プロジェクト: mauve/Pash
 internal void SetPipelineProcessor(PipelineProcessor pipelineProcessor)
 {
     CommandRuntime.PipelineProcessor = pipelineProcessor;
 }
コード例 #8
0
ファイル: LocalPipeline.cs プロジェクト: Ventero/Pash
        PipelineProcessor BuildPipelineProcessor(ExecutionContext context)
        {
            PipelineProcessor pipelineProcessor = new PipelineProcessor();

            // TODO: implement script execution
            foreach (Command command in Commands)
            {
                CommandProcessorBase commandProcessor;

                commandProcessor = command.CreateCommandProcessor(context, _runspace.CommandManager, false);
                pipelineProcessor.Add(commandProcessor);
            }

            return pipelineProcessor;
        }
コード例 #9
0
ファイル: LocalPipeline.cs プロジェクト: b333z/Pash
        PipelineProcessor BuildPipelineProcessor(ExecutionContext context)
        {
            PipelineProcessor pipelineProcessor = new PipelineProcessor();

            // TODO: implement script execution
            foreach (Command command in Commands)
            {
                CommandProcessorBase commandProcessor;

                try
                {
                    commandProcessor = command.CreateCommandProcessor(context, _runspace.CommandManager, false);
                }
                catch (PowerShellGrammar.ParseException exception)
                {
                    _runspace.PSHost.UI.WriteErrorLine("parse error at " + exception.LogMessage.Location.ToUiString());
                    return null;
                }
                catch (Exception exception)
                {
                    _runspace.PSHost.UI.WriteErrorLine(exception.GetType().Name + ": " + exception.Message);
                    return null;
                }

                commandProcessor.Initialize();
                pipelineProcessor.Add(commandProcessor);
            }

            return pipelineProcessor;
        }
コード例 #10
0
ファイル: LocalPipeline.cs プロジェクト: prateek/Pash
        PipelineProcessor BuildPipelineProcessor(ExecutionContext context)
        {
            PipelineProcessor pipelineProcessor = new PipelineProcessor();

            // TODO: implement script execution
            foreach (Command command in Commands)
            {
                CommandProcessorBase commandProcessor;

                try
                {
                    commandProcessor = command.CreateCommandProcessor(context, _runspace.CommandManager, false);
                }
                catch (PowerShellGrammar.ParseException exception)
                {
                    // nicer error message
                    throw new ParseException("Parse error at " + exception.LogMessage.Location.ToUiString(), exception);
                }
                pipelineProcessor.Add(commandProcessor);
            }

            return pipelineProcessor;
        }
コード例 #11
0
ファイル: LocalPipeline.cs プロジェクト: JamesTryand/Pash2
        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;

                try
                {
                    commandProcessor = command.CreateCommandProcessor(context, _runspace.CommandManager, false);
                }
                catch (PowerShellGrammar.ParseException exception)
                {
                    _runspace.PSHost.UI.WriteErrorLine("parse error at " + exception.LogMessage.Location.ToUiString());
                    return null;
                }

                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();
        }