Esempio n. 1
0
        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
        {
            if (handle.IsNullHandle())
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
            }

#if MONO
            MethodBase m = RuntimeMethodInfo.GetMethodFromHandleInternalType(handle.Value, IntPtr.Zero);
            if (m == null)
            {
                throw new ArgumentException("The handle is invalid.");
            }
#else
            MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());
#endif

            Type declaringType = m.DeclaringType;
            if (declaringType != null && declaringType.IsGenericType)
            {
                throw new ArgumentException(String.Format(
                                                CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"),
                                                m, declaringType.GetGenericTypeDefinition()));
            }

            return(m);
        }
Esempio n. 2
0
        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
        {
            if (handle.IsNullHandle())
            {
                throw new ArgumentException(SR.Argument_InvalidHandle);
            }
            MethodBase m = RuntimeMethodInfo.GetMethodFromHandleInternalType(handle.Value, declaringType.Value);

            if (m == null)
            {
                throw new ArgumentException(SR.Argument_InvalidHandle);
            }
            return(m);
        }
Esempio n. 3
0
        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
        {
            if (handle.IsNullHandle())
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
            }
#if MONO
            MethodBase m = RuntimeMethodInfo.GetMethodFromHandleInternalType(handle.Value, declaringType.Value);
            if (m == null)
            {
                throw new ArgumentException("The handle is invalid.");
            }
            return(m);
#else
            return(RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo()));
#endif
        }
Esempio n. 4
0
        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
        {
            if (handle.IsNullHandle())
            {
                throw new ArgumentException(SR.Argument_InvalidHandle);
            }

            MethodBase m = RuntimeMethodInfo.GetMethodFromHandleInternalType(handle.Value, IntPtr.Zero);

            if (m == null)
            {
                throw new ArgumentException(SR.Argument_InvalidHandle);
            }

            Type declaringType = m.DeclaringType;

            if (declaringType != null && declaringType.IsGenericType)
            {
                throw new ArgumentException(string.Format(SR.Argument_MethodDeclaringTypeGeneric,
                                                          m, declaringType.GetGenericTypeDefinition()));
            }

            return(m);
        }