GetFieldFromHandle() public static method

public static GetFieldFromHandle ( RuntimeFieldHandle handle ) : FieldInfo
handle RuntimeFieldHandle
return FieldInfo
Esempio n. 1
0
        /// <summary>Returns the field identified by the specified metadata token, in the context defined by the specified generic type parameters.</summary>
        /// <returns>A <see cref="T:System.Reflection.FieldInfo" /> object representing the field that is identified by the specified metadata token.</returns>
        /// <param name="metadataToken">A metadata token that identifies a field 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 field in the scope of the current module.-or-<paramref name="metadataToken" /> identifies a field whose parent TypeSpec has a signature containing 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 FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
        {
            ResolveTokenError error;
            IntPtr            intPtr = Module.ResolveFieldToken(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, "Field");
            }
            return(FieldInfo.GetFieldFromHandle(new RuntimeFieldHandle(intPtr)));
        }
Esempio n. 2
0
        internal static FieldInfo ResolveField(Module module, IntPtr monoModule, int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
        {
            ResolveTokenError error;

            IntPtr handle = ResolveFieldToken(monoModule, metadataToken, ptrs_from_types(genericTypeArguments), ptrs_from_types(genericMethodArguments), out error);

            if (handle == IntPtr.Zero)
            {
                throw resolve_token_exception(module.Name, metadataToken, error, "Field");
            }
            else
            {
                return(FieldInfo.GetFieldFromHandle(new RuntimeFieldHandle(handle)));
            }
        }