/// <summary> /// Override BeginProcessing. /// </summary> protected override void BeginProcessing() { if (!UseBrowser.IsPresent) { // Since UseBrowser is not bound, we use proxy to Out-Default stepPipe = ScriptBlock.Create(@"Microsoft.PowerShell.Core\Out-Default @PSBoundParameters").GetSteppablePipeline(this.MyInvocation.CommandOrigin); stepPipe.Begin(this); } }
/// <summary> /// Implements the begin action of the command /// </summary> protected override void BeginProcessing() { object outBuffer; if (MyInvocation.BoundParameters.TryGetValue("OutBuffer", out outBuffer)) { MyInvocation.BoundParameters["OutBuffer"] = 1; } Hashtable clonedBoundParameters = new Hashtable(); foreach (string key in MyInvocation.BoundParameters.Keys) { if (!_NonclonedProperties.Contains(key)) { clonedBoundParameters[key] = MyInvocation.BoundParameters[key]; } } if (MyInvocation.BoundParameters.ContainsKey("Property")) { clonedBoundParameters["Property"] = Property.Select(o => o.Value).AsEnumerable().ToArray(); } if ((ShowExcludeProperty.Length > 0) || (ShowProperty.Length > 0) || (!String.IsNullOrEmpty(TypeName)) || (KeepInputObject.ToBool())) { _NoAdjustment = false; } if (ShowProperty.Length > 0) { _DisplayPropertySet = new PSMemberInfo[] { new PSPropertySet("DefaultDisplayPropertySet", ShowProperty) } } ; // Set the list of parameters to a variable in the caller scope, so it can be splatted this.SessionState.PSVariable.Set("__PSFramework_SelectParam", clonedBoundParameters); ScriptBlock scriptCommand = ScriptBlock.Create("Select-Object @__PSFramework_SelectParam"); _Pipeline = scriptCommand.GetSteppablePipeline(MyInvocation.CommandOrigin); if (_NoAdjustment) { _Pipeline.Begin(this); } else { _Pipeline.Begin(true); } }
/// <summary> /// BeginProcessing override. /// </summary> protected override void BeginProcessing() { _stepPipeline = s_pwsh.GetSteppablePipeline(); _stepPipeline.Begin(this); }
protected override void BeginProcessing() { if (base.InvokeAndDisconnect && this.asjob) { throw new InvalidOperationException(RemotingErrorIdStrings.AsJobAndDisconnectedError); } if ((base.InvokeAndDisconnect && ((this.ComputerName == null) || (this.ComputerName.Length == 0))) && ((this.ConnectionUri == null) || (this.ConnectionUri.Length == 0))) { throw new InvalidOperationException(RemotingErrorIdStrings.InvokeDisconnectedWithoutComputerName); } if (base.MyInvocation.BoundParameters.ContainsKey("SessionName") && !base.InvokeAndDisconnect) { throw new InvalidOperationException(RemotingErrorIdStrings.SessionNameWithoutInvokeDisconnected); } if (base.ParameterSetName.Equals("InProcess")) { if (this.FilePath != null) { this.ScriptBlock = base.GetScriptBlockFromFile(this.FilePath, false); } if (base.MyInvocation.ExpectingInput && !this.ScriptBlock.IsUsingDollarInput()) { try { this.steppablePipeline = this.ScriptBlock.GetSteppablePipeline(); this.steppablePipeline.Begin(this); } catch (InvalidOperationException) { } } } else { base.BeginProcessing(); foreach (IThrottleOperation operation in base.Operations) { this.inputWriters.Add(((ExecutionCmdletHelper)operation).Pipeline.Input); } if (base.ParameterSetName.Equals("Session")) { long instanceId = ((LocalRunspace)base.Context.CurrentRunspace).GetCurrentlyRunningPipeline().InstanceId; foreach (PSSession session in this.Session) { RemoteRunspace runspace = (RemoteRunspace)session.Runspace; if (runspace.IsAnotherInvokeCommandExecuting(this, instanceId)) { if (((base.MyInvocation != null) && (base.MyInvocation.PipelinePosition == 1)) && !base.MyInvocation.ExpectingInput) { PSPrimitiveDictionary dictionary = session.ApplicationPrivateData["PSVersionTable"] as PSPrimitiveDictionary; if (dictionary != null) { Version version = dictionary["PSRemotingProtocolVersion"] as Version; if ((version != null) && (version >= RemotingConstants.ProtocolVersionWin8RTM)) { this.needToCollect = false; this.needToStartSteppablePipelineOnServer = true; break; } } } this.needToCollect = true; this.needToStartSteppablePipelineOnServer = false; break; } } } if (this.needToStartSteppablePipelineOnServer) { foreach (IThrottleOperation operation2 in base.Operations) { ExecutionCmdletHelperRunspace runspace2 = operation2 as ExecutionCmdletHelperRunspace; if (runspace2 == null) { break; } runspace2.ShouldUseSteppablePipelineOnServer = true; } } else { this.clearInvokeCommandOnRunspace = true; } this.DetermineThrowStatementBehavior(); } }