Exemple #1
0
 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();
     }
 }
Exemple #2
0
 internal Executor(PowwaHost parent, bool useNestedPipelines, bool isPromptFunctionExecutor)
 {
     this.instanceStateLock        = new object();
     this.parent                   = parent;
     this.useNestedPipelines       = useNestedPipelines;
     this.isPromptFunctionExecutor = isPromptFunctionExecutor;
     this.Reset();
 }
Exemple #3
0
        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);
        }