Beispiel #1
0
        /// <summary>Returns the method or constructor identified by the specified metadata token, in the context defined by the specified generic type parameters. </summary>
        /// <returns>A <see cref="T:System.Reflection.MethodBase" /> object representing the method that is identified by the specified metadata token.</returns>
        /// <param name="metadataToken">A metadata token that identifies a method or constructor in the module.</param>
        /// <param name="genericTypeArguments">An array of <see cref="T:System.Type" /> objects representing the generic type arguments of the type where the token is in scope, or null if that type is not generic. </param>
        /// <param name="genericMethodArguments">An array of <see cref="T:System.Type" /> objects representing the generic type arguments of the method where the token is in scope, or null if that method is not generic.</param>
        /// <exception cref="T:System.ArgumentException">
        ///   <paramref name="metadataToken" /> is not a token for a method or constructor in the scope of the current module.-or-<paramref name="metadataToken" /> is a MethodSpec whose signature contains element type var (a type parameter of a generic type) or mvar (a type parameter of a generic method), and the necessary generic type arguments were not supplied for either or both of <paramref name="genericTypeArguments" /> and <paramref name="genericMethodArguments" />.</exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="metadataToken" /> is not a valid token in the scope of the current module.</exception>
        public MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
        {
            ResolveTokenError error;
            IntPtr            intPtr = Module.ResolveMethodToken(this._impl, metadataToken, this.ptrs_from_types(genericTypeArguments), this.ptrs_from_types(genericMethodArguments), out error);

            if (intPtr == IntPtr.Zero)
            {
                throw this.resolve_token_exception(metadataToken, error, "MethodBase");
            }
            return(MethodBase.GetMethodFromHandleNoGenericCheck(new RuntimeMethodHandle(intPtr)));
        }