/// <summary> /// Handle host call received /// </summary> /// <param name="sender">sender of this event, unused</param> /// <param name="eventArgs">arguments describing the host call to invoke</param> private void HandleHostCallReceived(object sender, RemoteDataEventArgs <RemoteHostCall> eventArgs) { ClientMethodExecutor.Dispatch( _powershell.RemotePowerShell.DataStructureHandler.TransportManager, ((RemoteRunspace)_runspace).RunspacePool.RemoteRunspacePoolInternal.Host, _errorStream, MethodExecutorStream, IsMethodExecutorStreamEnabled, ((RemoteRunspace)_runspace).RunspacePool.RemoteRunspacePoolInternal, _powershell.InstanceId, eventArgs.Data); }
/// <summary> /// Handle the object obtained from an ObjectStream's reader /// based on its type. /// </summary> /// <param name="cmdlet">Cmdlet to use for outputting the object.</param> /// <param name="overrideInquire">Used by Receive-Job to suppress inquire preference.</param> public void WriteStreamObject(Cmdlet cmdlet, bool overrideInquire = false) { if (cmdlet != null) { switch (this.ObjectType) { case PSStreamObjectType.Output: { cmdlet.WriteObject(this.Value); } break; case PSStreamObjectType.Error: { ErrorRecord errorRecord = (ErrorRecord)this.Value; errorRecord.PreserveInvocationInfoOnce = true; MshCommandRuntime mshCommandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; if (mshCommandRuntime != null) { mshCommandRuntime.WriteError(errorRecord, overrideInquire); } } break; case PSStreamObjectType.Debug: { string debug = (string)Value; DebugRecord debugRecord = new DebugRecord(debug); MshCommandRuntime mshCommandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; if (mshCommandRuntime != null) { mshCommandRuntime.WriteDebug(debugRecord, overrideInquire); } } break; case PSStreamObjectType.Warning: { string warning = (string)Value; WarningRecord warningRecord = new WarningRecord(warning); MshCommandRuntime mshCommandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; if (mshCommandRuntime != null) { mshCommandRuntime.WriteWarning(warningRecord, overrideInquire); } } break; case PSStreamObjectType.Verbose: { string verbose = (string)Value; VerboseRecord verboseRecord = new VerboseRecord(verbose); MshCommandRuntime mshCommandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; if (mshCommandRuntime != null) { mshCommandRuntime.WriteVerbose(verboseRecord, overrideInquire); } } break; case PSStreamObjectType.Progress: { MshCommandRuntime mshCommandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; if (mshCommandRuntime != null) { mshCommandRuntime.WriteProgress((ProgressRecord)Value, overrideInquire); } } break; case PSStreamObjectType.Information: { MshCommandRuntime mshCommandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; if (mshCommandRuntime != null) { mshCommandRuntime.WriteInformation((InformationRecord)Value, overrideInquire); } } break; case PSStreamObjectType.WarningRecord: { WarningRecord warningRecord = (WarningRecord)Value; MshCommandRuntime mshCommandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; if (mshCommandRuntime != null) { mshCommandRuntime.AppendWarningVarList(warningRecord); } } break; case PSStreamObjectType.MethodExecutor: { Dbg.Assert(this.Value is ClientMethodExecutor, "Expected psstreamObject.value is ClientMethodExecutor"); ClientMethodExecutor methodExecutor = (ClientMethodExecutor)Value; methodExecutor.Execute(cmdlet); } break; case PSStreamObjectType.BlockingError: { CmdletMethodInvoker <object> methodInvoker = (CmdletMethodInvoker <object>)Value; InvokeCmdletMethodAndWaitForResults(methodInvoker, cmdlet); } break; case PSStreamObjectType.ShouldMethod: { CmdletMethodInvoker <bool> methodInvoker = (CmdletMethodInvoker <bool>)Value; InvokeCmdletMethodAndWaitForResults(methodInvoker, cmdlet); } break; case PSStreamObjectType.Exception: { Exception e = (Exception)Value; throw e; } } } else if (ObjectType == PSStreamObjectType.Exception) { Exception e = (Exception)Value; throw e; } }
private void HandleHostCallReceived(object sender, RemoteDataEventArgs <RemoteHostCall> eventArgs) { ClientMethodExecutor.Dispatch(this._runspacePool.RemoteRunspacePoolInternal.DataStructureHandler.TransportManager, this._runspacePool.RemoteRunspacePoolInternal.Host, null, null, false, this._runspacePool.RemoteRunspacePoolInternal, Guid.Empty, eventArgs.Data); }