Module.ResolveType Module.ResolveType Module.ResolveType Module.ResolveType Method

定义

返回由元数据令牌标识的类型。Returns the type identified by a metadata token.

重载

ResolveType(Int32) ResolveType(Int32) ResolveType(Int32) ResolveType(Int32)

返回由指定的元数据令牌标识的类型。Returns the type identified by the specified metadata token.

ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的类型。Returns the type identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveType(Int32) ResolveType(Int32) ResolveType(Int32) ResolveType(Int32)

返回由指定的元数据令牌标识的类型。Returns the type identified by the specified metadata token.

public:
 Type ^ ResolveType(int metadataToken);
public Type ResolveType (int metadataToken);
member this.ResolveType : int -> Type
Public Function ResolveType (metadataToken As Integer) As Type

参数

metadataToken
Int32 Int32 Int32 Int32

一个元数据令牌,用于标识模块中的一个类型。A metadata token that identifies a type in the module.

返回

一个 Type 对象,表示由指定的元数据令牌标识的类型。A Type object representing the type that is identified by the specified metadata token.

异常

metadataToken 不是当前模块范围内的类型的令牌。metadataToken is not a token for a type in the scope of the current module.

- 或 --or- metadataToken 是一个 TypeSpec,其签名包含元素类型 var(泛型类型的类型参数)或 mvar(泛型方法的类型参数)。metadataToken is a TypeSpec whose signature contains element type var (a type parameter of a generic type) or mvar (a type parameter of a generic method).

metadataToken 不是当前模块范围内的有效令牌。metadataToken is not a valid token in the scope of the current module.

注解

若要解析的元数据标记TypeSpec (其签名ELEMENT_TYPE_VAR包含ELEMENT_TYPE_MVAR或), ResolveType(Int32, Type[], Type[])请使用方法重载,这允许你提供必要的上下文。To resolve a metadata token for a TypeSpec whose signature contains ELEMENT_TYPE_VAR or ELEMENT_TYPE_MVAR, use the ResolveType(Int32, Type[], Type[]) method overload, which allows you to supply the necessary context. 也就是说,当你为依赖于泛型类型的泛型类型参数和/或嵌入了标记的泛型方法的类型的元数据标记进行解析时,必须使用允许提供这些类型参数的重载。That is, when you are resolving a metadata token for a type that depends on the generic type parameters of the generic type and/or the generic method in which the token is embedded, you must use the overload that allows you to supply those type parameters.

备注

有关元数据令牌的信息,请参阅公共语言基础结构(CLI)文档,尤其是 "第二部分:元数据定义和语义 "。Information about metadata tokens can be found in the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics". 文档在线提供;请参阅在 ECMA 网站上的 MSDN 和标准 ecma-335-公共语言基础结构(CLI)上的ECMA C#和公共语言基础结构标准The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the ECMA Web site.

ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的类型。Returns the type identified by the specified metadata token, in the context defined by the specified generic type parameters.

public:
 Type ^ ResolveType(int metadataToken, cli::array <Type ^> ^ genericTypeArguments, cli::array <Type ^> ^ genericMethodArguments);
public Type ResolveType (int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments);
member this.ResolveType : int * Type[] * Type[] -> Type
Public Function ResolveType (metadataToken As Integer, genericTypeArguments As Type(), genericMethodArguments As Type()) As Type

参数

metadataToken
Int32 Int32 Int32 Int32

一个元数据令牌,用于标识模块中的一个类型。A metadata token that identifies a type in the module.

genericTypeArguments
Type[]

一个 Type 对象的数组,表示以下类型的泛型类型参数,在该类型中,令牌在范围内;如果该类型不是泛型类型,则为 nullAn array of Type objects representing the generic type arguments of the type where the token is in scope, or null if that type is not generic.

genericMethodArguments
Type[]

一个 Type 对象的数组,表示以下方法的泛型类型参数,在该方法中,令牌在范围内;如果该方法不是泛型方法,则为 nullAn array of Type objects representing the generic type arguments of the method where the token is in scope, or null if that method is not generic.

返回

一个 Type 对象,表示由指定的元数据令牌标识的类型。A Type object representing the type that is identified by the specified metadata token.

异常

metadataToken 不是当前模块范围内的类型的令牌。metadataToken is not a token for a type in the scope of the current module.

-or- metadataToken 是一个 TypeSpec,其签名包含元素类型 var(泛型类型的类型参数)或 mvar(泛型方法的类型参数),并且没有为 genericTypeArguments 和(或)genericMethodArguments 提供必要的泛型类型参数。metadataToken is a TypeSpec 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 genericTypeArguments and genericMethodArguments.

metadataToken 不是当前模块范围内的有效令牌。metadataToken is not a valid token in the scope of the current module.

注解

在类型中对类型使用metadataToken genericTypeArguments方法,其中在范围内可获取的泛型类型参数的数组。 Type.GetGenericArgumentsUse the Type.GetGenericArguments method on the type where metadataToken is in scope to obtain an array of generic type arguments for genericTypeArguments. 对方法使用metadataToken genericTypeArguments方法,其中在范围内可获取的泛型类型参数的数组。 MethodInfo.GetGenericArgumentsUse the MethodInfo.GetGenericArguments method on the method where metadataToken is in scope to obtain an array of generic type arguments for genericTypeArguments. 提供这些参数始终是安全的,即使不需要它们也是如此。It is always safe to provide these arguments, even when they are not needed.

备注

有关元数据令牌的信息,请参阅公共语言基础结构(CLI)文档,尤其是 "第二部分:元数据定义和语义 "。Information about metadata tokens can be found in the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics". 文档在线提供;请参阅在 ECMA 网站上的 MSDN 和标准 ecma-335-公共语言基础结构(CLI)上的ECMA C#和公共语言基础结构标准The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the ECMA Web site.

有关使用一般上下文(即,泛型类型的泛型类型参数和/或泛型方法的泛型类型参数,其中嵌入了标记)的代码,请参阅ResolveMethod(Int32, Type[], Type[])方法。For code that demonstrates token resolution using the generic context (that is, the generic type parameters of the generic type and/or the generic method in which the token is embedded) see the ResolveMethod(Int32, Type[], Type[]) method.

适用于