public static Action <T1, TCallback> GetAsyncAction <T1, TCallback>( #if !NET_2_0 this #endif HproseInvoker invoker, string methodName, HproseErrorEvent errorEvent) { return(delegate(T1 a1, TCallback callback) { AsyncInvoke(invoker, methodName, new object[] { a1 }, callback, errorEvent); }); }
internal AsyncInvokeContextBase(HproseClient client, string functionName, object[] arguments, HproseErrorEvent errorCallback, Type returnType, bool byRef, HproseResultMode resultMode) { this.client = client; this.functionName = functionName; this.arguments = arguments; this.errorCallback = errorCallback; this.returnType = returnType; this.byRef = byRef; this.resultMode = resultMode; }
public AsyncInvokeContextBase(HproseClient client, string functionName, object[] arguments, HproseErrorEvent errorCallback, Type returnType, bool byRef, HproseResultMode resultMode, bool simple) { this.client = client; this.functionName = functionName; this.arguments = arguments; this.errorCallback = (errorCallback == null) ? client.OnError : errorCallback; this.returnType = returnType; this.byRef = byRef; this.resultMode = resultMode; this.simple = simple; this.syncContext = HproseClient.SynchronizationContext; }
private static void AsyncInvoke <TCallback>(HproseInvoker invoker, string methodName, object[] args, TCallback callback, HproseErrorEvent errorEvent) { if (callback is HproseCallback) { invoker.Invoke(methodName, args, callback as HproseCallback, errorEvent); } else if (callback is HproseCallback1) { invoker.Invoke(methodName, args, callback as HproseCallback1, errorEvent); } else { #if Core TypeInfo type = callback.GetType().GetTypeInfo(); if (type.IsGenericType) { if (type.GetGenericTypeDefinition() == typeof(HproseCallback <>)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(type.GenericTypeArguments)) as IInvokeHelper; helper.Invoke(invoker, methodName, args, callback as Delegate, errorEvent, false, HproseResultMode.Normal, false); return; } else if (type.GetGenericTypeDefinition() == typeof(HproseCallback1 <>)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(type.GenericTypeArguments)) as IInvokeHelper1; helper.Invoke(invoker, methodName, args, callback as Delegate, errorEvent, HproseResultMode.Normal, false); return; } } #else Type type = callback.GetType(); if (type.IsGenericType) { if (type.GetGenericTypeDefinition() == typeof(HproseCallback <>)) { IInvokeHelper helper = Activator.CreateInstance(typeof(InvokeHelper <>).MakeGenericType(type.GetGenericArguments())) as IInvokeHelper; helper.Invoke(invoker, methodName, args, callback as Delegate, errorEvent, false, HproseResultMode.Normal, false); return; } else if (type.GetGenericTypeDefinition() == typeof(HproseCallback1 <>)) { IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(type.GetGenericArguments())) as IInvokeHelper1; helper.Invoke(invoker, methodName, args, callback as Delegate, errorEvent, HproseResultMode.Normal, false); return; } } #endif throw new Exception("TCallback must be a Callback Delegate: HproseCallback, HproseCallback1, HproseCallback<T>, HproseCallback1<T>."); } }
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(string functionName, HproseCallback1 callback, HproseErrorEvent errorEvent, HproseResultMode resultMode) { Invoke(functionName, nullArgs, callback, errorEvent, null, resultMode); }
public void Invoke(string functionName, HproseCallback1 callback, HproseErrorEvent errorEvent, Type returnType) { Invoke(functionName, nullArgs, callback, errorEvent, returnType, HproseResultMode.Normal); }
public void Invoke(string functionName, HproseCallback callback, HproseErrorEvent errorEvent) { Invoke(functionName, nullArgs, callback, errorEvent, null, false, HproseResultMode.Normal); }
public void Invoke <T>(string functionName, HproseCallback1 <T> callback, HproseErrorEvent errorEvent) { Invoke(functionName, nullArgs, callback, errorEvent); }
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(); }
internal AsyncInvokeContext(HproseClient client, string functionName, object[] arguments, HproseCallback callback, HproseErrorEvent errorCallback, Type returnType, bool byRef, HproseResultMode resultMode, bool simple) : base(client, functionName, arguments, errorCallback, returnType, byRef, resultMode, simple) { this.callback = callback; }
public void Invoke(string functionName, object[] arguments, HproseCallback callback, HproseErrorEvent errorEvent, Type returnType, bool byRef, HproseResultMode resultMode, bool simple) { (new AsyncInvokeContext(this, functionName, arguments, callback, errorEvent, returnType, byRef, resultMode, simple)).Invoke(); }
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 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)); }
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)); } } }
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 <T>(string functionName, object[] arguments, HproseCallback <T> callback, HproseErrorEvent errorEvent) { Invoke(functionName, arguments, callback, errorEvent, false); }
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 <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, HproseCallback callback, HproseErrorEvent errorEvent, Type returnType, HproseResultMode resultMode) { Invoke(functionName, nullArgs, callback, errorEvent, returnType, false, resultMode, false); }
public void Invoke(string functionName, object[] arguments, HproseCallback callback, HproseErrorEvent errorEvent, bool byRef) { Invoke(functionName, arguments, callback, errorEvent, null, byRef, HproseResultMode.Normal); }
public void Invoke(string functionName, object[] arguments, HproseCallback callback, HproseErrorEvent errorEvent, Type returnType, bool byRef, HproseResultMode resultMode) { Invoke(functionName, arguments, callback, errorEvent, returnType, byRef, resultMode, false); }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorEvent, Type returnType) { Invoke(functionName, arguments, callback, errorEvent, returnType, HproseResultMode.Normal); }
internal AsyncInvokeContextBase(HproseClient client, string functionName, object[] arguments, HproseErrorEvent errorCallback, Type returnType, bool byRef, HproseResultMode resultMode) { this.client = client; this.functionName = functionName; this.arguments = arguments; this.errorCallback = errorCallback; this.returnType = returnType; this.byRef = byRef; this.resultMode = resultMode; this.syncContext = HproseClient.SynchronizationContext; }
public void Invoke(string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorEvent, HproseResultMode resultMode) { Invoke(functionName, arguments, 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 void Invoke(HproseInvoker invoker, string functionName, object[] args, Delegate callback, HproseErrorEvent errorEvent, HproseResultMode resultMode, bool simple) { invoker.Invoke <T>(functionName, args, (HproseCallback1 <T>)callback, errorEvent, resultMode, simple); }
public AsyncInvokeContextBase(HproseClient client, string functionName, object[] arguments, HproseErrorEvent errorCallback, Type returnType, bool byRef, HproseResultMode resultMode, bool simple) { this.client = client; this.functionName = functionName; this.arguments = arguments; this.errorCallback = (errorCallback == null) ? client.OnError : errorCallback; this.returnType = returnType; this.byRef = byRef; this.resultMode = resultMode; this.simple = simple; this.syncContext = HproseClient.SynchronizationContext; this.context = new HproseClientContext(client); }