TypeProvider.GetType 方法

定义

获取通过搜索添加的程序集引用和代码编译单元而传递的限定类型名中的 TypeGets the Type from the qualified type name passed by searching through the assembly references and code compile units that are added.

重载

GetType(String)

从使用 TypeProviderAddAssembly(Assembly)AddAssemblyReference(String) 添加到 AddCodeCompileUnit(CodeCompileUnit) 的一组程序集中获取类型。Gets the type from the set of assemblies added to the TypeProvider using AddAssembly(Assembly), AddAssemblyReference(String), or AddCodeCompileUnit(CodeCompileUnit).

GetType(String, Boolean)

从使用 TypeProviderAddAssembly(Assembly)AddAssemblyReference(String) 添加到 AddCodeCompileUnit(CodeCompileUnit) 的一组程序集中获取类型。Gets the type from the set of assemblies added to the TypeProvider using AddAssembly(Assembly), AddAssemblyReference(String), or AddCodeCompileUnit(CodeCompileUnit).

GetType(String)

从使用 TypeProviderAddAssembly(Assembly)AddAssemblyReference(String) 添加到 AddCodeCompileUnit(CodeCompileUnit) 的一组程序集中获取类型。Gets the type from the set of assemblies added to the TypeProvider using AddAssembly(Assembly), AddAssemblyReference(String), or AddCodeCompileUnit(CodeCompileUnit).

public:
 virtual Type ^ GetType(System::String ^ name);
public Type GetType (string name);
override this.GetType : string -> Type
Public Function GetType (name As String) As Type

参数

name
String

类型名称。The type name.

返回

请求的 TypeThe requested Type.

实现

例外

name 为空引用(在 Visual Basic 中为 Nothingname is a null reference (Nothing in Visual Basic)

注解

如果名称在程序集的缓存和此实例的编译单元中不能解析,将返回一个空引用(在 Visual Basic 中为 Nothing)。If the name is not resolvable within the cache of assemblies and compiled units of this instance, a null reference (Visual Basic Nothing) is returned. 调用此重载与调用参数 throwOnError 的值设置为 true 的两参数重载相同。Invoking this overload is the same as invoking the two parameter overloads with the value of the parameter throwOnError set to true.

GetType(String, Boolean)

从使用 TypeProviderAddAssembly(Assembly)AddAssemblyReference(String) 添加到 AddCodeCompileUnit(CodeCompileUnit) 的一组程序集中获取类型。Gets the type from the set of assemblies added to the TypeProvider using AddAssembly(Assembly), AddAssemblyReference(String), or AddCodeCompileUnit(CodeCompileUnit).

public:
 virtual Type ^ GetType(System::String ^ name, bool throwOnError);
public Type GetType (string name, bool throwOnError);
override this.GetType : string * bool -> Type
Public Function GetType (name As String, throwOnError As Boolean) As Type

参数

name
String

类型名称。The type name.

throwOnError
Boolean

一个指示 name 不可解析时是否引发异常的值。A value that indicates whether to throw an exception if name is not resolvable.

返回

请求的 TypeThe requested Type.

实现

例外

name 为空引用(在 Visual Basic 中为 Nothingname is a null reference (Nothing in Visual Basic)

name 不可解析,因此 throwOnErrortruename is not resolvable and throwOnError is true.

注解

如果名称在程序集的缓存和此实例的编译单元中不可解析,则返回一个空引用 (Nothing),前提是 throwOnErrorfalseIf the name is not resolvable within the cache of assemblies and compiled units of this instance, a null reference (Nothing) is returned; in the case that throwOnError is false.

适用于