Type.GetConstructorImpl 方法

定义

在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定参数类型和修饰符匹配的构造函数。

protected:
 abstract System::Reflection::ConstructorInfo ^ GetConstructorImpl(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, System::Reflection::CallingConventions callConvention, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
protected abstract System.Reflection.ConstructorInfo? GetConstructorImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[]? modifiers);
protected abstract System.Reflection.ConstructorInfo GetConstructorImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
protected abstract System.Reflection.ConstructorInfo? GetConstructorImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[]? modifiers);
[<System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)>]
abstract member GetConstructorImpl : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
abstract member GetConstructorImpl : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
Protected MustOverride Function GetConstructorImpl (bindingAttr As BindingFlags, binder As Binder, callConvention As CallingConventions, types As Type(), modifiers As ParameterModifier()) As ConstructorInfo

参数

bindingAttr
BindingFlags

枚举值的按位组合,用于指定如何执行搜索。

-或-

Default null返回 。

binder
Binder

一个对象,定义一组属性并启用绑定,这可能涉及选择重载的方法、强制参数类型以及通过反射调用成员。

-或-

null 引用(Visual Basic 中的 Nothing),以使用 DefaultBinder

callConvention
CallingConventions

指定用于参数顺序和布局的规则集、传递返回值的方式、用于参数的寄存器以及清理堆栈的对象。

types
Type[]

一个 Type 对象数组,表示要获取的构造函数的参数的数量、顺序和类型。

-或-

类型(即 Type[] types = new Type[0])的 Type 空数组,用于获取不带参数的构造函数。

modifiers
ParameterModifier[]

表示与数组中ParameterModifier相应元素关联的属性的对象数组types。 默认绑定器不处理此参数。

返回

一个 ConstructorInfo 对象,表示与指定要求匹配的构造函数的对象,如果找到,则为 ;否则为 null

属性

例外

typesnull

-或-

其中 types 一个元素是 null

types 是多维。

-或-

modifiers 是多维。

-或-

typesmodifiers 长度不相同。

注解

尽管默认联编程序不处理 ParameterModifiermodifiers 参数),但可以使用抽象 System.Reflection.Binder 类编写一个处理自定义 modifiers联编程序。 ParameterModifier 仅在通过 COM 互作调用时使用,并且仅处理通过引用传递的参数。

如果完全匹配不存在, binder 将尝试强制指定在数组中指定的 types 参数类型,以便选择匹配项。 binder如果无法选择匹配项,则null返回。

以下 BindingFlags 筛选器标志可用于定义要在搜索中包含哪些构造函数:

  • 您必须指定BindingFlags.InstanceBindingFlags.Static才能获得返回结果。

  • 指定 BindingFlags.Public 在搜索中包含公共构造函数。

  • 指定 BindingFlags.NonPublic 在搜索中包含非公共构造函数(即专用构造函数、内部构造函数和受保护的构造函数)。

有关详细信息,请参阅 System.Reflection.BindingFlags

此方法实现 GetConstructor

适用于

另请参阅