private void Start(bool incomingStream) { if (this.disposed) { throw PSTraceSource.NewObjectDisposedException("PipelineProcessor"); } if (this.Stopping) { throw new PipelineStoppedException(); } if (!this.executionStarted) { if ((this._commands == null) || (this._commands.Count == 0)) { throw PSTraceSource.NewInvalidOperationException("PipelineStrings", "PipelineExecuteRequiresAtLeastOneCommand", new object[0]); } CommandProcessorBase base2 = this._commands[0]; if ((base2 == null) || (base2.CommandRuntime == null)) { throw PSTraceSource.NewInvalidOperationException("PipelineStrings", "PipelineExecuteRequiresAtLeastOneCommand", new object[0]); } if (this.executionScope == null) { this.executionScope = base2.Context.EngineSessionState.CurrentScope; } CommandProcessorBase base3 = this._commands[this._commands.Count - 1]; if ((base3 == null) || (base3.CommandRuntime == null)) { throw PSTraceSource.NewInvalidOperationException(); } if (this.ExternalSuccessOutput != null) { base3.CommandRuntime.OutputPipe.ExternalWriter = this.ExternalSuccessOutput; } this.SetExternalErrorOutput(); if ((this.ExternalInput == null) && !incomingStream) { base2.CommandRuntime.IsClosed = true; } IDictionary variableValue = base2.Context.GetVariableValue(SpecialVariables.PSDefaultParameterValuesVarPath, false) as IDictionary; this.executionStarted = true; int[] numArray = new int[this._commands.Count + 1]; for (int i = 0; i < this._commands.Count; i++) { CommandProcessorBase base4 = this._commands[i]; if (base4 == null) { throw PSTraceSource.NewInvalidOperationException(); } Guid engineActivityId = base4.Context.CurrentRunspace.EngineActivityId; Guid activityId = EtwActivity.CreateActivityId(); EtwActivity.SetActivityId(activityId); base4.PipelineActivityId = activityId; MshLog.LogCommandLifecycleEvent(base4.Context, CommandState.Started, base4.Command.MyInvocation); InvocationInfo myInvocation = base4.Command.MyInvocation; myInvocation.PipelinePosition = i + 1; myInvocation.PipelineLength = this._commands.Count; myInvocation.PipelineIterationInfo = numArray; base4.DoPrepare(variableValue); myInvocation.ExpectingInput = base4.IsPipelineInputExpected(); } this.SetupOutErrorVariable(); for (int j = 0; j < this._commands.Count; j++) { this._commands[j].DoBegin(); } } }