Esempio n. 1
0
        private static ProxyMethodResolverContext Resolve(object[] args)
        {
            PackedArgs packed = new PackedArgs(args);
            MethodBase method = s_proxyAssembly.ResolveMethodToken(packed.DeclaringType, packed.MethodToken);

            if (method.IsGenericMethodDefinition)
            {
                method = ((MethodInfo)method).MakeGenericMethod(packed.GenericTypes);
            }

            return(new ProxyMethodResolverContext(packed, method));
        }
Esempio n. 2
0
        private static void Invoke(object[] args)
        {
            PackedArgs packed = new PackedArgs(args);
            MethodBase method = s_proxyAssembly.ResolveMethodToken(packed.DeclaringType, packed.MethodToken);

            if (method.IsGenericMethodDefinition)
            {
                method = ((MethodInfo)method).MakeGenericMethod(packed.GenericTypes);
            }

            try
            {
                Debug.Assert(s_dispatchProxyInvokeMethod != null);
                object returnValue = s_dispatchProxyInvokeMethod.Invoke(packed.DispatchProxy,
                                                                        new object[] { method, packed.Args });
                packed.ReturnValue = returnValue;
            }
            catch (Exception tie)
            {
                throw new Exception();
            }
        }
Esempio n. 3
0
        // All generated proxy methods call this static helper method to dispatch.
        // Its job is to unpack the arguments and the 'this' instance and to dispatch directly
        // to the (abstract) DispatchProxy.Invoke() method.
        private static void Invoke(object[] args)
        {
            PackedArgs packed = new PackedArgs(args);
            MethodBase method = s_proxyAssembly.ResolveMethodToken(packed.DeclaringType, packed.MethodToken);

            if (method.IsGenericMethodDefinition)
            {
                method = ((MethodInfo)method).MakeGenericMethod(packed.GenericTypes);
            }

            // Call (protected method) DispatchProxy.Invoke()
            try
            {
                Debug.Assert(s_dispatchProxyInvokeMethod != null);
                object returnValue = s_dispatchProxyInvokeMethod.Invoke(packed.DispatchProxy,
                                                                        new object[] { method, packed.Args });
                packed.ReturnValue = returnValue;
            }
            catch (TargetInvocationException tie)
            {
                ExceptionDispatchInfo.Capture(tie.InnerException).Throw();
            }
        }
Esempio n. 4
0
        // this method is the callback from the RealProxy
        static void Invoke(object[] args)
        {
            PackedArgs packed = new PackedArgs(args);
            MethodBase method = proxyAssembly.ResolveMethodToken(packed.DeclaringType, packed.MethodToken);

            if (method.IsGenericMethodDefinition)
            {
                method = ((MethodInfo)method).MakeGenericMethod(packed.GenericTypes);
            }

            MethodCallMessage mcm = new MethodCallMessage(method, packed.Args, packed.GenericTypes);

            ReturnMessage mrm = (ReturnMessage)packed.RealProxy.Invoke(mcm);

            if (mrm.Exception != null)
            {
                throw mrm.Exception;
            }
            else
            {
                packed.ReturnValue = mrm.ReturnValue;
            }
        }
 public ProxyMethodResolverContext(PackedArgs packed, MethodBase method)
 {
     Packed = packed;
     Method = method;
 }