Ejemplo n.º 1
0
        private static void AsyncInvoke <TCallback>(HproseClient client, string methodName, object[] args, TCallback callback)
        {
            if (callback is HproseCallback)
            {
                client.Invoke(methodName, args, callback as HproseCallback);
            }
            else if (callback is HproseCallback1)
            {
                client.Invoke(methodName, args, callback as HproseCallback1);
            }
            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(client, methodName, args, callback as Delegate, false);
                        return;
                    }
                    else if (type.GetGenericTypeDefinition() == typeof(HproseCallback1 <>))
                    {
                        IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(type.GenericTypeArguments)) as IInvokeHelper1;
                        helper.Invoke(client, methodName, args, callback as Delegate);
                        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(client, methodName, args, callback as Delegate, false);
                        return;
                    }
                    else if (type.GetGenericTypeDefinition() == typeof(HproseCallback1 <>))
                    {
                        IInvokeHelper1 helper = Activator.CreateInstance(typeof(InvokeHelper1 <>).MakeGenericType(type.GetGenericArguments())) as IInvokeHelper1;
                        helper.Invoke(client, methodName, args, callback as Delegate);
                        return;
                    }
                }
#endif
                throw new Exception("TCallback must be a Callback Delegate: HproseCallback, HproseCallback1, HproseCallback<T>, HproseCallback1<T>.");
            }
        }
Ejemplo n.º 2
0
        public static Action <T1, T2, T3, T4, T5> GetAction <T1, T2, T3, T4, T5>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) {
                client.Invoke(methodName, new object[] { a1, a2, a3, a4, a5 });
            });
        }
Ejemplo n.º 3
0
        public static Action <T1, T2> GetAction <T1, T2>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate(T1 a1, T2 a2) {
                client.Invoke(methodName, new object[] { a1, a2 });
            });
        }
Ejemplo n.º 4
0
        public static Action GetAction(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate() {
                client.Invoke(methodName);
            });
        }
Ejemplo n.º 5
0
        public static Func <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> GetFunc <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9, T10 a10, T11 a11, T12 a12, T13 a13, T14 a14, T15 a15, T16 a16) {
                return client.Invoke <TResult>(methodName, new object[] { a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 });
            });
        }
Ejemplo n.º 6
0
        public static Func <T1, T2, T3, T4, T5, T6, T7, T8, TResult> GetFunc <T1, T2, T3, T4, T5, T6, T7, T8, TResult>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8) {
                return client.Invoke <TResult>(methodName, new object[] { a1, a2, a3, a4, a5, a6, a7, a8 });
            });
        }
Ejemplo n.º 7
0
        public static Func <T1, T2, T3, TResult> GetFunc <T1, T2, T3, TResult>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate(T1 a1, T2 a2, T3 a3) {
                return client.Invoke <TResult>(methodName, new object[] { a1, a2, a3 });
            });
        }
Ejemplo n.º 8
0
        public static Func <TResult> GetFunc <TResult>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate() {
                return client.Invoke <TResult>(methodName);
            });
        }
Ejemplo n.º 9
0
        public static Action <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> GetAction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9, T10 a10, T11 a11, T12 a12, T13 a13, T14 a14, T15 a15) {
                client.Invoke(methodName, new object[] { a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 });
            });
        }
Ejemplo n.º 10
0
        public static Action <T1, T2, T3, T4, T5, T6, T7, T8, T9> GetAction <T1, T2, T3, T4, T5, T6, T7, T8, T9>(
#if !NET_2_0
            this
#endif
            HproseClient client, string methodName)
        {
            return(delegate(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, T8 a8, T9 a9) {
                client.Invoke(methodName, new object[] { a1, a2, a3, a4, a5, a6, a7, a8, a9 });
            });
        }