Пример #1
0
 private void DoCompleteCore(CommandProcessorBase commandRequestingUpstreamCommandsToStop)
 {
     for (int i = 0; i < this._commands.Count; i++)
     {
         CommandProcessorBase objB = this._commands[i];
         if (objB == null)
         {
             throw PSTraceSource.NewInvalidOperationException();
         }
         if (object.ReferenceEquals(commandRequestingUpstreamCommandsToStop, objB))
         {
             commandRequestingUpstreamCommandsToStop = null;
         }
         else if (commandRequestingUpstreamCommandsToStop == null)
         {
             try
             {
                 objB.DoComplete();
             }
             catch (PipelineStoppedException)
             {
                 StopUpstreamCommandsException firstTerminatingError = this.firstTerminatingError as StopUpstreamCommandsException;
                 if (firstTerminatingError == null)
                 {
                     throw;
                 }
                 this.firstTerminatingError = null;
                 commandRequestingUpstreamCommandsToStop = firstTerminatingError.RequestingCommandProcessor;
             }
             EtwActivity.SetActivityId(objB.PipelineActivityId);
             MshLog.LogCommandLifecycleEvent(objB.Command.Context, CommandState.Stopped, objB.Command.MyInvocation);
         }
     }
     if (this.firstTerminatingError != null)
     {
         this.LogExecutionException(this.firstTerminatingError);
         throw this.firstTerminatingError;
     }
 }
Пример #2
0
        internal Array SynchronousExecuteEnumerate(object input, Hashtable errorResults, bool enumerate)
        {
            if (this.Stopping)
            {
                throw new PipelineStoppedException();
            }
            Exception exception = null;

            try
            {
                CommandProcessorBase commandRequestingUpstreamCommandsToStop = null;
                try
                {
                    this.Start(input != AutomationNull.Value);
                    CommandProcessorBase base3 = this._commands[0];
                    if (this.ExternalInput != null)
                    {
                        base3.CommandRuntime.InputPipe.ExternalReader = this.ExternalInput;
                    }
                    this.Inject(input, enumerate);
                }
                catch (PipelineStoppedException)
                {
                    StopUpstreamCommandsException firstTerminatingError = this.firstTerminatingError as StopUpstreamCommandsException;
                    if (firstTerminatingError == null)
                    {
                        throw;
                    }
                    this.firstTerminatingError = null;
                    commandRequestingUpstreamCommandsToStop = firstTerminatingError.RequestingCommandProcessor;
                }
                this.DoCompleteCore(commandRequestingUpstreamCommandsToStop);
                if (this._redirectionPipes != null)
                {
                    foreach (PipelineProcessor processor in this._redirectionPipes)
                    {
                        processor.DoCompleteCore(null);
                    }
                }
                return(this.RetrieveResults(errorResults));
            }
            catch (RuntimeException exception3)
            {
                if (this.firstTerminatingError != null)
                {
                    exception = this.firstTerminatingError;
                }
                else
                {
                    exception = exception3;
                }
                this.LogExecutionException(exception);
            }
            catch (InvalidComObjectException exception4)
            {
                if (this.firstTerminatingError != null)
                {
                    exception = this.firstTerminatingError;
                }
                else
                {
                    exception = new RuntimeException(StringUtil.Format(ParserStrings.InvalidComObjectException, exception4.Message), exception4);
                    ((RuntimeException)exception).SetErrorId("InvalidComObjectException");
                }
                this.LogExecutionException(exception);
            }
            finally
            {
                this.DisposeCommands();
            }
            RuntimeException.LockStackTrace(exception);
            throw exception;
        }