public Object Invoke(Object proxy, MethodInfo method, Object[] args) { //don't proxy toString, hashCode, or equals if (method.DeclaringType.Equals(typeof(object))) { return(method.Invoke(this, args)); } //partition arguments into arguments that can //be simply marshalled as part of the request and //those that are response handlers IList <Object> simpleMarshallArgs = CollectionUtil.NewList(args); ObjectStreamHandler streamHandlerArg = ExtractStreamHandler(ReflectionUtil.GetParameterTypes(method), simpleMarshallArgs); //build the request object RemoteConnectorInfoImpl connectorInfo = (RemoteConnectorInfoImpl)_configuration.ConnectorInfo; RemoteFrameworkConnectionInfo connectionInfo = connectorInfo.RemoteConnectionInfo; OperationRequest request = new OperationRequest( connectorInfo.ConnectorKey, _configuration, _operation, method.Name, simpleMarshallArgs); //create the connection RemoteFrameworkConnection connection = new RemoteFrameworkConnection(connectionInfo); try { connection.WriteObject(CultureInfo.CurrentUICulture); connection.WriteObject(connectionInfo.Key); //send the request connection.WriteObject(request); //now process each response stream (if any) if (streamHandlerArg != null) { HandleStreamResponse(connection, streamHandlerArg); } //finally return the actual return value OperationResponsePart response = (OperationResponsePart)connection.ReadObject(); if (response.Exception != null) { throw response.Exception; } return(response.Result); } finally { connection.Dispose(); } }
public Object Invoke(Object proxy, MethodInfo method, Object[] args) { //don't proxy toString, hashCode, or equals if (method.DeclaringType.Equals(typeof(object))) { return method.Invoke(this, args); } //partition arguments into arguments that can //be simply marshalled as part of the request and //those that are response handlers IList<Object> simpleMarshallArgs = CollectionUtil.NewList(args); ObjectStreamHandler streamHandlerArg = ExtractStreamHandler(ReflectionUtil.GetParameterTypes(method), simpleMarshallArgs); //build the request object RemoteFrameworkConnectionInfo connectionInfo = _connectorInfo.RemoteConnectionInfo; OperationRequest request = new OperationRequest( _connectorInfo.ConnectorKey, _connectorFacadeKey, _operation, method.Name, simpleMarshallArgs); //create the connection RemoteFrameworkConnection connection = new RemoteFrameworkConnection(connectionInfo); try { connection.WriteObject(CultureInfo.CurrentUICulture); connection.WriteObject(connectionInfo.Key); //send the request connection.WriteObject(request); //now process each response stream (if any) if (streamHandlerArg != null) { HandleStreamResponse(connection, streamHandlerArg); } //finally return the actual return value OperationResponsePart response = (OperationResponsePart)connection.ReadObject(); if (response.Exception != null) { throw response.Exception; } return response.Result; } finally { connection.Dispose(); } }