internal Collection <PSObject> ExecuteCommandHelper(Pipeline tempPipeline, out Exception exceptionThrown, Executor.ExecutionOptions options) { exceptionThrown = null; Collection <PSObject> pSObjects = null; if ((options & Executor.ExecutionOptions.AddOutputter) > Executor.ExecutionOptions.None) { if (tempPipeline.Commands.Count == 1) { tempPipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); } Command command = new Command("Out-Default", false, new bool?(true), true); tempPipeline.Commands.Add(command); } lock (this.instanceStateLock) { this.pipeline = tempPipeline; } try { try { pSObjects = tempPipeline.Invoke(); } catch (Exception exception1) { Exception exception = exception1; PowwaHost.CheckForSevereException(exception); exceptionThrown = exception; } } finally { this.parent.ResetProgress(); this.Reset(); } return(pSObjects); }
internal void ExecuteCommandAsync(string command, out Exception exceptionThrown, Executor.ExecutionOptions options) { bool flag = (options & Executor.ExecutionOptions.AddToHistory) > Executor.ExecutionOptions.None; Pipeline pipeline = this.parent.RunspaceRef.CreatePipeline(command, flag, false); this.ExecuteCommandAsyncHelper(pipeline, out exceptionThrown, options); }
internal void ExecuteCommandAsyncHelper(Pipeline tempPipeline, out Exception exceptionThrown, Executor.ExecutionOptions options) { exceptionThrown = null; lock (this.instanceStateLock) { this.pipeline = tempPipeline; } try { try { if ((options & Executor.ExecutionOptions.AddOutputter) > Executor.ExecutionOptions.None && this.parent.OutputFormat == Serialization.DataFormat.Text) { if (tempPipeline.Commands.Count == 1) { tempPipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output); } Command command = new Command("Out-Default", false, true); tempPipeline.Commands.Add(command); } tempPipeline.Output.DataReady += new EventHandler(this.OutputObjectStreamHandler); tempPipeline.Error.DataReady += new EventHandler(this.ErrorObjectStreamHandler); tempPipeline.StateChanged += HandleStateChanged; tempPipeline.InvokeAsync(); if ((options & Executor.ExecutionOptions.ReadInputObjects) > Executor.ExecutionOptions.None && this.parent.IsStandardInputRedirected) { WrappedDeserializer wrappedDeserializer = new WrappedDeserializer(this.parent.InputFormat, "Input", this.parent.StandardInReader); while (!wrappedDeserializer.AtEnd) { object obj = wrappedDeserializer.Deserialize(); if (obj == null) { break; } try { tempPipeline.Input.Write(obj); } catch (PipelineClosedException pipelineClosedException) { break; } } wrappedDeserializer.End(); } tempPipeline.Input.Close(); } catch (Exception exception1) { Exception exception = exception1; PowwaHost.CheckForSevereException(exception); exceptionThrown = exception; } } finally { this.parent.ResetProgress(); this.Reset(); } }
internal Collection <PSObject> ExecuteCommand(string command, out Exception exceptionThrown, Executor.ExecutionOptions options) { Pipeline pipeline = this.CreatePipeline(command, (options & Executor.ExecutionOptions.AddToHistory) > Executor.ExecutionOptions.None); return(this.ExecuteCommandHelper(pipeline, out exceptionThrown, options)); }