Esempio n. 1
0
		public CADMessageBase (IMethodMessage msg) {
			CADMethodRef methodRef = new CADMethodRef (msg);
			serializedMethod = CADSerializer.SerializeObject (methodRef).GetBuffer ();
		}
Esempio n. 2
0
        internal MethodBase GetMethod()
        {
            CADMethodRef methRef = (CADMethodRef)CADSerializer.DeserializeObjectSafe(serializedMethod);

            MethodBase _method;

            Type tt = Type.GetType(methRef.FullTypeName, true);

            if (tt.IsGenericType || tt.IsGenericTypeDefinition)
            {
                _method = MethodBase.GetMethodFromHandleNoGenericCheck(methRef.MethodHandle);
            }
            else
            {
                _method = MethodBase.GetMethodFromHandle(methRef.MethodHandle);
            }

            if (tt != _method.DeclaringType)
            {
                // The target domain has loaded the type from a different assembly.
                // We need to locate the correct type and get the method from it
                Type [] signature = GetSignature(_method, true);
                if (_method.IsGenericMethod)
                {
                    MethodBase [] methods   = tt.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                    Type []       base_args = _method.GetGenericArguments();
                    foreach (MethodBase method in methods)
                    {
                        if (!method.IsGenericMethod || method.Name != _method.Name)
                        {
                            continue;
                        }
                        Type [] method_args = method.GetGenericArguments();
                        if (base_args.Length != method_args.Length)
                        {
                            continue;
                        }

                        MethodInfo method_instance = ((MethodInfo)method).MakeGenericMethod(base_args);
                        Type []    base_sig        = GetSignature(method_instance, false);
                        if (base_sig.Length != signature.Length)
                        {
                            continue;
                        }
                        bool dont = false;
                        for (int i = base_sig.Length - 1; i >= 0; i--)
                        {
                            if (base_sig [i] != signature [i])
                            {
                                dont = true;
                                break;
                            }
                        }
                        if (dont)
                        {
                            continue;
                        }
                        return(method_instance);
                    }
                    return(_method);
                }

                MethodBase mb = tt.GetMethod(_method.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, signature, null);
                if (mb == null)
                {
                    throw new RemotingException("Method '" + _method.Name + "' not found in type '" + tt + "'");
                }
                return(mb);
            }
            return(_method);
        }
Esempio n. 3
0
        public CADMessageBase(IMethodMessage msg)
        {
            CADMethodRef methodRef = new CADMethodRef(msg);

            serializedMethod = CADSerializer.SerializeObject(methodRef).GetBuffer();
        }
Esempio n. 4
0
        internal MethodBase GetMethod()
        {
            CADMethodRef methRef = (CADMethodRef)CADSerializer.DeserializeObjectSafe(serializedMethod);

            return(methRef.Resolve());
        }