/// <summary> /// Execute method. /// </summary> internal T ExecuteMethod <T>(RemoteHostMethodId methodId, object[] parameters) { Dbg.Assert(parameters != null, "Expected parameters != null"); // Create the method call object. long callId = _serverDispatchTable.CreateNewCallId(); RemoteHostCall remoteHostCall = new RemoteHostCall(callId, methodId, parameters); RemoteDataObject <PSObject> dataToBeSent = RemoteDataObject <PSObject> .CreateFrom(RemotingDestination.Client, _remoteHostCallDataType, _clientRunspacePoolId, _clientPowerShellId, remoteHostCall.Encode()); // report that execution is pending host response _transportManager.SendDataToClient(dataToBeSent, false, true); // Wait for response. RemoteHostResponse remoteHostResponse = _serverDispatchTable.GetResponse(callId, null); // Null means that the response PSObject was not received and there was an error. if (remoteHostResponse == null) { throw RemoteHostExceptions.NewRemoteHostCallFailedException(methodId); } // Process the response. object returnValue = remoteHostResponse.SimulateExecution(); Dbg.Assert(returnValue is T, "Expected returnValue is T"); return((T)remoteHostResponse.SimulateExecution()); }
internal T ExecuteMethod <T>(RemoteHostMethodId methodId, object[] parameters) { long newCallId = this._serverDispatchTable.CreateNewCallId(); this._transportManager.SendDataToClient <PSObject>(RemoteDataObject <PSObject> .CreateFrom(RemotingDestination.Client, this._remoteHostCallDataType, this._clientRunspacePoolId, this._clientPowerShellId, new RemoteHostCall(newCallId, methodId, parameters).Encode()), false); RemoteHostResponse response = this._serverDispatchTable.GetResponse(newCallId, (RemoteHostResponse)null); if (response == null) { throw RemoteHostExceptions.NewRemoteHostCallFailedException(methodId); } response.SimulateExecution(); return((T)response.SimulateExecution()); }