private void Button_Click_1(object sender, RoutedEventArgs e) { //HproseClient.SynchronizationContext = SynchronizationContext.Current; HproseHttpClient client = new HproseHttpClient("http://localhost:2012/"); ISendUsers proxyObject = client.UseService <ISendUsers>(); var SendUsers = client.GetFunc <List <User>, List <User> >("sendUsers"); var AsyncSendUsers = client.GetAsyncAction <List <User>, HproseCallback1 <List <User> > >("sendUsers"); List <User> users = new List <User>(); User user1 = new User(); user1.name = "李雷"; user1.age = 32; user1.male = true; user1.friends = new List <User>(); User user2 = new User(); user2.name = "韩梅梅"; user2.age = 31; user2.male = false; user2.friends = new List <User>(); user1.friends.Add(user2); user2.friends.Add(user1); users.Add(user1); users.Add(user2); MemoryStream stream = HproseFormatter.Serialize(users); byte[] bytes = stream.ToArray(); System.Windows.Browser.HtmlPage.Window.Eval("alert('" + UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length) + "')"); HproseCallback1 <List <User> > callback = result => { MemoryStream s = HproseFormatter.Serialize(result); byte[] b = s.ToArray(); System.Windows.Browser.HtmlPage.Window.Eval("alert('" + UTF8Encoding.UTF8.GetString(b, 0, b.Length) + "')"); }; proxyObject.SendUsers(users, callback); AsyncSendUsers(users, callback); new Thread(() => { byte[] b = proxyObject.SendUsersRaw(users); Dispatcher.BeginInvoke(() => { System.Windows.Browser.HtmlPage.Window.Eval("alert('" + UTF8Encoding.UTF8.GetString(b, 0, b.Length) + "')"); }); MemoryStream ss = HproseFormatter.Serialize(SendUsers(users)); byte[] bb = ss.ToArray(); Dispatcher.BeginInvoke(() => { System.Windows.Browser.HtmlPage.Window.Eval("alert('" + UTF8Encoding.UTF8.GetString(bb, 0, bb.Length) + "')"); }); string result = proxyObject.Hello("World"); Dispatcher.BeginInvoke(() => { System.Windows.Browser.HtmlPage.Window.Eval("alert('" + result + "')"); }); }).Start(); }
private void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorEvent, Type returnType, HproseResultMode resultMode) { if (errorEvent == null) { errorEvent = OnError; } AsyncInvokeContext1 context = new AsyncInvokeContext1(this, functionName, arguments, callback, errorEvent, returnType, resultMode); try { BeginGetOutputStream(new AsyncCallback(context.GetOutputStream), GetInvokeContext()); } catch (Exception e) { if (errorEvent != null) { errorEvent(functionName, e); } } }
public void Invoke <T>(string functionName, object[] arguments, HproseCallback1 <T> callback, HproseErrorEvent errorEvent) { if (errorEvent == null) { errorEvent = OnError; } AsyncInvokeContext1 <T> context = new AsyncInvokeContext1 <T>(this, functionName, arguments, callback, errorEvent); try { BeginGetOutputStream(new AsyncCallback(context.GetOutputStream), GetInvokeContext()); } catch (Exception e) { if (errorEvent != null) { errorEvent(functionName, e); } } }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorEvent, Type returnType, HproseResultMode resultMode, bool simple) { new Thread(new ThreadStart(delegate() { try { Object result = Invoke(functionName, arguments, returnType, false, resultMode, simple); callback(result); } catch (Exception ex) { if (errorEvent != null) { errorEvent(functionName, ex); } else if (OnError != null) { OnError(functionName, ex); } } })).Start(); }
public void Invoke <T>(string functionName, HproseCallback1 <T> callback) { Invoke(functionName, nullArgs, callback, null); }
internal AsyncInvokeContext1(HproseClient client, string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorCallback, Type returnType, HproseResultMode resultMode) : base(client, functionName, arguments, errorCallback, returnType, false, resultMode) { this.callback = callback; }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorEvent, HproseResultMode resultMode) { Invoke(functionName, arguments, callback, errorEvent, null, resultMode); }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorEvent, Type returnType) { Invoke(functionName, arguments, callback, errorEvent, returnType, HproseResultMode.Normal); }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback) { Invoke(functionName, arguments, callback, null, null, HproseResultMode.Normal); }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorEvent, bool simple) { Invoke(functionName, arguments, callback, errorEvent, null, HproseResultMode.Normal, simple); }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, Type returnType) { Invoke(functionName, arguments, callback, null, returnType, HproseResultMode.Normal, false); }
public void Invoke <T>(string functionName, object[] arguments, HproseCallback1 <T> callback, HproseErrorEvent errorEvent, HproseResultMode resultMode, bool simple) { (new AsyncInvokeContext1 <T>(this, functionName, arguments, callback, errorEvent, resultMode, simple)).Invoke(); }
public void Invoke(string functionName, HproseCallback1 callback, HproseErrorEvent errorEvent) { Invoke(functionName, nullArgs, callback, errorEvent, null, HproseResultMode.Normal, false); }
public void Invoke <T>(string functionName, object[] arguments, HproseCallback1 <T> callback, HproseErrorEvent errorEvent) { Invoke(functionName, arguments, callback, errorEvent, HproseResultMode.Normal, false); }
public void Invoke <T>(string functionName, object[] arguments, HproseCallback1 <T> callback, bool simple) { Invoke(functionName, arguments, callback, null, HproseResultMode.Normal, simple); }
public void Invoke <T>(string functionName, HproseCallback1 <T> callback, HproseResultMode resultMode) { Invoke(functionName, nullArgs, callback, null, resultMode, false); }
public void Invoke <T>(string functionName, object[] arguments, HproseCallback1 <T> callback) { Invoke(functionName, arguments, callback, null); }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseResultMode resultMode) { Invoke(functionName, arguments, callback, null, null, resultMode, false); }
public void Invoke <T>(string functionName, HproseCallback1 <T> callback, HproseErrorEvent errorEvent) { Invoke(functionName, nullArgs, callback, errorEvent); }
public void Invoke(string functionName, HproseCallback1 callback, Type returnType, HproseResultMode resultMode) { Invoke(functionName, nullArgs, callback, null, returnType, resultMode, false); }
public void Invoke(string functionName, HproseCallback1 callback) { Invoke(functionName, nullArgs, callback, null, null, HproseResultMode.Normal); }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, Type returnType, HproseResultMode resultMode, bool simple) { Invoke(functionName, arguments, callback, null, returnType, resultMode, simple); }
public void Invoke(string functionName, HproseCallback1 callback, HproseErrorEvent errorEvent, Type returnType) { Invoke(functionName, nullArgs, callback, errorEvent, returnType, HproseResultMode.Normal); }
public object Invoke(object proxy, MethodInfo method, object[] args) { ParameterInfo[] parameters = method.GetParameters(); HproseResultMode resultMode = HproseResultMode.Normal; bool simple = false; string methodName = method.Name; #if dotNET45 Attribute rmAttr = method.GetCustomAttribute(typeof(ResultModeAttribute), true); if (rmAttr != null) { resultMode = (rmAttr as ResultModeAttribute).Value; } Attribute smAttr = method.GetCustomAttribute(typeof(SimpleModeAttribute), true); if (smAttr != null) { simple = (smAttr as SimpleModeAttribute).Value; } Attribute mnAttr = method.GetCustomAttribute(typeof(MethodNameAttribute), true); if (mnAttr != null) { methodName = (mnAttr as MethodNameAttribute).Value; } #else object[] resultModes = method.GetCustomAttributes(typeof(ResultModeAttribute), true); if (resultModes.Length == 1) { resultMode = (resultModes[0] as ResultModeAttribute).Value; } object[] simpleModes = method.GetCustomAttributes(typeof(SimpleModeAttribute), true); if (simpleModes.Length == 1) { simple = (simpleModes[0] as SimpleModeAttribute).Value; } object[] methodNames = method.GetCustomAttributes(typeof(MethodNameAttribute), true); if (methodNames.Length == 1) { methodName = (methodNames[0] as MethodNameAttribute).Value; } #endif if (ns != null && ns != "") { methodName = ns + '_' + methodName; } Type returnType = method.ReturnType; CheckResultType(resultMode, returnType); bool byRef = false; Type[] paramTypes = GetTypes(parameters); foreach (Type param in paramTypes) { if (param.IsByRef) { byRef = true; break; } } #if dotNET45 #if Core if (returnType.GetTypeInfo().IsGenericType&& returnType.GetGenericTypeDefinition() == typeof(Task <>)) { ITaskCreator taskCreator = Activator.CreateInstance(typeof(TaskCreator <>).MakeGenericType(returnType.GenericTypeArguments)) as ITaskCreator; #else if (returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Task <>)) { ITaskCreator taskCreator = Activator.CreateInstance(typeof(TaskCreator <>).MakeGenericType(returnType.GetGenericArguments())) as ITaskCreator; #endif return(taskCreator.GetTask(invoker, methodName, args, byRef, resultMode, simple)); } if (returnType == typeof(Task)) { return(Task.Run(delegate() { invoker.Invoke(methodName, args, (Type)null, byRef, resultMode, simple); })); } #endif int n = paramTypes.Length; if ((n > 0) && (paramTypes[n - 1] == typeof(HproseCallback))) { HproseCallback callback = (HproseCallback)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); invoker.Invoke(methodName, tmpargs, callback, byRef, resultMode, simple); return(null); } if ((n > 0) && (paramTypes[n - 1] == typeof(HproseCallback1))) { HproseCallback1 callback = (HproseCallback1)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); invoker.Invoke(methodName, tmpargs, callback); return(null); } if ((n > 1) && (paramTypes[n - 2] == typeof(HproseCallback)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback callback = (HproseCallback)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); invoker.Invoke(methodName, tmpargs, callback, returnType, byRef, resultMode, simple); return(null); } if ((n > 1) && (paramTypes[n - 2] == typeof(HproseCallback1)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback1 callback = (HproseCallback1)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); invoker.Invoke(methodName, tmpargs, callback, returnType, resultMode, simple); return(null); } if ((n > 2) && (paramTypes[n - 3] == typeof(HproseCallback)) && (paramTypes[n - 2] == typeof(HproseErrorEvent)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback callback = (HproseCallback)args[n - 3]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 3]; Array.Copy(args, 0, tmpargs, 0, n - 3); invoker.Invoke(methodName, tmpargs, callback, errorEvent, returnType, byRef, resultMode, simple); return(null); } if ((n > 2) && (paramTypes[n - 3] == typeof(HproseCallback1)) && (paramTypes[n - 2] == typeof(HproseErrorEvent)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback1 callback = (HproseCallback1)args[n - 3]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 3]; Array.Copy(args, 0, tmpargs, 0, n - 3); invoker.Invoke(methodName, tmpargs, callback, errorEvent, returnType, resultMode, simple); return(null); } #if !(dotNET10 || dotNET11 || dotNETCF10) #if Core if ((n > 0) && paramTypes[n - 1].GetTypeInfo().IsGenericType&& paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback <>)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper; #else if ((n > 0) && paramTypes[n - 1].IsGenericType && paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback <>)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper; #endif Delegate callback = (Delegate)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); helper.Invoke(invoker, methodName, tmpargs, callback, null, byRef, resultMode, simple); return(null); } #if Core if ((n > 0) && paramTypes[n - 1].GetTypeInfo().IsGenericType&& paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback1 <>)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper1; #else if ((n > 0) && paramTypes[n - 1].IsGenericType && paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback1 <>)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper1; #endif Delegate callback = (Delegate)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); helper.Invoke(invoker, methodName, tmpargs, callback, null, resultMode, simple); return(null); } #if Core if ((n > 1) && paramTypes[n - 2].GetTypeInfo().IsGenericType&& paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper; #else if ((n > 1) && paramTypes[n - 2].IsGenericType && paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper; #endif Delegate callback = (Delegate)args[n - 2]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 1]; object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); helper.Invoke(invoker, methodName, tmpargs, callback, errorEvent, byRef, resultMode, simple); return(null); } #if Core if ((n > 1) && paramTypes[n - 2].GetTypeInfo().IsGenericType&& paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback1 <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper1; #else if ((n > 1) && paramTypes[n - 2].IsGenericType && paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback1 <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper1; #endif Delegate callback = (Delegate)args[n - 2]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 1]; object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); helper.Invoke(invoker, methodName, tmpargs, callback, errorEvent, resultMode, simple); return(null); } #endif if (returnType == typeof(void)) { returnType = null; } return(invoker.Invoke(methodName, args, returnType, byRef, resultMode, simple)); } } }
public void Invoke(string functionName, HproseCallback1 callback, HproseErrorEvent errorEvent, HproseResultMode resultMode) { Invoke(functionName, nullArgs, callback, errorEvent, null, resultMode); }
internal AsyncInvokeContext1(HproseClient client, string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorCallback, Type returnType, HproseResultMode resultMode, bool simple) : base(client, functionName, arguments, errorCallback, returnType, false, resultMode, simple) { this.callback = callback; }
public object Invoke(object proxy, MethodInfo method, object[] args) { ParameterInfo[] parameters = method.GetParameters(); Type[] paramTypes = GetTypes(parameters); Type returnType = method.ReturnType; if (returnType == typeof(void)) { returnType = null; } int n = paramTypes.Length; string functionName = method.Name; if (ns != null) { functionName = ns + '_' + functionName; } bool byRef = false; foreach (Type param in paramTypes) { if (param.IsByRef) { byRef = true; break; } } if ((n > 0) && (paramTypes[n - 1] == typeof(HproseCallback))) { HproseCallback callback = (HproseCallback)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); client.Invoke(functionName, tmpargs, callback, byRef); return(null); } if ((n > 0) && (paramTypes[n - 1] == typeof(HproseCallback1))) { HproseCallback1 callback = (HproseCallback1)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); client.Invoke(functionName, tmpargs, callback); return(null); } if ((n > 1) && (paramTypes[n - 2] == typeof(HproseCallback)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback callback = (HproseCallback)args[n - 2]; returnType = (Type)args[n - 1]; object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); client.Invoke(functionName, tmpargs, callback, returnType, byRef); return(null); } if ((n > 1) && (paramTypes[n - 2] == typeof(HproseCallback1)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback1 callback = (HproseCallback1)args[n - 2]; returnType = (Type)args[n - 1]; object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); client.Invoke(functionName, tmpargs, callback, returnType); return(null); } #if !(dotNET10 || dotNET11 || dotNETCF10) if ((n > 0) && (paramTypes[n - 1].IsGenericType && (paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback <>)))) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper; Delegate callback = (Delegate)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); helper.Invoke(client, functionName, tmpargs, callback, byRef); return(null); } if ((n > 0) && (paramTypes[n - 1].IsGenericType && (paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback1 <>)))) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper1; Delegate callback = (Delegate)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); helper.Invoke(client, functionName, tmpargs, callback); return(null); } #endif #if SILVERLIGHT throw new HproseException("SilverLight do not support synchronous invoke."); #else object result = client.Invoke(functionName, args, returnType, byRef); if (result is Exception) { throw (Exception)result; } return(result); #endif }
public object Invoke(object proxy, string methodName, Type[] paramTypes, Type returnType, object[] attrs, object[] args) { #endif HproseResultMode resultMode = HproseResultMode.Normal; bool simple = false; bool byRef = false; #if !dotNETMF foreach (Type param in paramTypes) { if (param.IsByRef) { byRef = true; break; } } #endif foreach (object attr in attrs) { if (attr is ResultModeAttribute) { resultMode = (attr as ResultModeAttribute).Value; } else if (attr is SimpleModeAttribute) { simple = (attr as SimpleModeAttribute).Value; } else if (attr is ByRefAttribute) { byRef = (attr as ByRefAttribute).Value; } else if (attr is MethodNameAttribute) { methodName = (attr as MethodNameAttribute).Value; } } CheckResultType(resultMode, returnType); if (ns != null && ns != "") { methodName = ns + '_' + methodName; } #if (dotNET4 || SL5 || WP80) && !(SL4 || WP70 || WP71) #if Core if (returnType.GetTypeInfo().IsGenericType&& returnType.GetGenericTypeDefinition() == typeof(Task <>)) { ITaskCreator taskCreator = Activator.CreateInstance(typeof(TaskCreator <>).MakeGenericType(returnType.GenericTypeArguments)) as ITaskCreator; #else if (returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Task <>)) { ITaskCreator taskCreator = Activator.CreateInstance(typeof(TaskCreator <>).MakeGenericType(returnType.GetGenericArguments())) as ITaskCreator; #endif return(taskCreator.GetTask(invoker, methodName, args, byRef, resultMode, simple)); } if (returnType == typeof(Task)) { #if dotNET45 return(Task.Run(delegate() { invoker.Invoke(methodName, args, (Type)null, byRef, resultMode, simple); })); #else return(Task.Factory.StartNew(delegate() { invoker.Invoke(methodName, args, (Type)null, byRef, resultMode, simple); }, default(CancellationToken), TaskCreationOptions.None, TaskScheduler.Default)); #endif } #endif int n = paramTypes.Length; if ((n > 0) && (paramTypes[n - 1] == typeof(HproseCallback))) { HproseCallback callback = (HproseCallback)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); invoker.Invoke(methodName, tmpargs, callback, byRef, resultMode, simple); return(null); } if ((n > 0) && (paramTypes[n - 1] == typeof(HproseCallback1))) { HproseCallback1 callback = (HproseCallback1)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); invoker.Invoke(methodName, tmpargs, callback); return(null); } if ((n > 1) && (paramTypes[n - 2] == typeof(HproseCallback)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback callback = (HproseCallback)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); invoker.Invoke(methodName, tmpargs, callback, returnType, byRef, resultMode, simple); return(null); } if ((n > 1) && (paramTypes[n - 2] == typeof(HproseCallback1)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback1 callback = (HproseCallback1)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); invoker.Invoke(methodName, tmpargs, callback, returnType, resultMode, simple); return(null); } if ((n > 2) && (paramTypes[n - 3] == typeof(HproseCallback)) && (paramTypes[n - 2] == typeof(HproseErrorEvent)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback callback = (HproseCallback)args[n - 3]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 3]; Array.Copy(args, 0, tmpargs, 0, n - 3); invoker.Invoke(methodName, tmpargs, callback, errorEvent, returnType, byRef, resultMode, simple); return(null); } if ((n > 2) && (paramTypes[n - 3] == typeof(HproseCallback1)) && (paramTypes[n - 2] == typeof(HproseErrorEvent)) && (paramTypes[n - 1] == typeof(Type))) { HproseCallback1 callback = (HproseCallback1)args[n - 3]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 2]; returnType = (Type)args[n - 1]; CheckResultType(resultMode, returnType); object[] tmpargs = new object[n - 3]; Array.Copy(args, 0, tmpargs, 0, n - 3); invoker.Invoke(methodName, tmpargs, callback, errorEvent, returnType, resultMode, simple); return(null); } #if !(dotNET10 || dotNET11 || dotNETCF10 || dotNETMF) #if Core if ((n > 0) && paramTypes[n - 1].GetTypeInfo().IsGenericType&& paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback <>)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper; #else if ((n > 0) && paramTypes[n - 1].IsGenericType && paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback <>)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper; #endif Delegate callback = (Delegate)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); helper.Invoke(invoker, methodName, tmpargs, callback, null, byRef, resultMode, simple); return(null); } #if Core if ((n > 0) && paramTypes[n - 1].GetTypeInfo().IsGenericType&& paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback1 <>)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper1; #else if ((n > 0) && paramTypes[n - 1].IsGenericType && paramTypes[n - 1].GetGenericTypeDefinition() == typeof(HproseCallback1 <>)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper1; #endif Delegate callback = (Delegate)args[n - 1]; object[] tmpargs = new object[n - 1]; Array.Copy(args, 0, tmpargs, 0, n - 1); helper.Invoke(invoker, methodName, tmpargs, callback, null, resultMode, simple); return(null); } #if Core if ((n > 1) && paramTypes[n - 2].GetTypeInfo().IsGenericType&& paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper; #else if ((n > 1) && paramTypes[n - 2].IsGenericType && paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper; #endif Delegate callback = (Delegate)args[n - 2]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 1]; object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); helper.Invoke(invoker, methodName, tmpargs, callback, errorEvent, byRef, resultMode, simple); return(null); } #if Core if ((n > 1) && paramTypes[n - 2].GetTypeInfo().IsGenericType&& paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback1 <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GenericTypeArguments)) as IInvokeHelper1; #else if ((n > 1) && paramTypes[n - 2].IsGenericType && paramTypes[n - 2].GetGenericTypeDefinition() == typeof(HproseCallback1 <>) && paramTypes[n - 1] == typeof(HproseErrorEvent)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(paramTypes[n - 1].GetGenericArguments())) as IInvokeHelper1; #endif Delegate callback = (Delegate)args[n - 2]; HproseErrorEvent errorEvent = (HproseErrorEvent)args[n - 1]; object[] tmpargs = new object[n - 2]; Array.Copy(args, 0, tmpargs, 0, n - 2); helper.Invoke(invoker, methodName, tmpargs, callback, errorEvent, resultMode, simple); return(null); } #endif if (returnType == typeof(void)) { returnType = null; } return(invoker.Invoke(methodName, args, returnType, byRef, resultMode, simple)); }