public void TestOperationRequest() { ConfigurationPropertiesImpl configProperties = new ConfigurationPropertiesImpl(); configProperties.Properties = (new List<ConfigurationPropertyImpl>()); APIConfigurationImpl apiImpl = new APIConfigurationImpl(); apiImpl.ConfigurationProperties = (configProperties); IList<object> args = new List<object>(); args.Add("my arg"); OperationRequest v1 = new OperationRequest(new ConnectorKey("my bundle", "my version", "my connector"), SerializerUtil.SerializeBase64Object(apiImpl), SafeType<APIOperation>.Get<CreateApiOp>(), "mymethodName", args); OperationRequest v2 = (OperationRequest)CloneObject(v1); Assert.AreEqual("my bundle", v2.ConnectorKey.BundleName); Assert.AreEqual("my version", v2.ConnectorKey.BundleVersion); Assert.AreEqual("my connector", v2.ConnectorKey.ConnectorName); Assert.IsNotNull(v2.ConnectorFacadeKey); Assert.AreEqual(SafeType<APIOperation>.Get<CreateApiOp>(), v2.Operation); Assert.AreEqual("mymethodName", v2.OperationMethodName); Assert.IsTrue( CollectionUtil.Equals( args, v2.Arguments)); }
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(); } }