Type.GetConstructorImpl 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定参数类型和修饰符匹配的构造函数。
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
参数
- binder
- Binder
一个对象,定义一组属性并启用绑定,这可能涉及选择重载的方法、强制参数类型以及通过反射调用成员。
-或-
null 引用(Visual Basic 中的 Nothing),以使用 DefaultBinder。
- callConvention
- CallingConventions
指定用于参数顺序和布局的规则集、传递返回值的方式、用于参数的寄存器以及清理堆栈的对象。
- types
- Type[]
一个 Type 对象数组,表示要获取的构造函数的参数的数量、顺序和类型。
-或-
类型(即 Type[] types = new Type[0])的 Type 空数组,用于获取不带参数的构造函数。
- modifiers
- ParameterModifier[]
表示与数组中ParameterModifier相应元素关联的属性的对象数组types。 默认绑定器不处理此参数。
返回
一个 ConstructorInfo 对象,表示与指定要求匹配的构造函数的对象,如果找到,则为 ;否则为 null。
- 属性
例外
注解
尽管默认联编程序不处理 ParameterModifier ( modifiers 参数),但可以使用抽象 System.Reflection.Binder 类编写一个处理自定义 modifiers联编程序。
ParameterModifier 仅在通过 COM 互作调用时使用,并且仅处理通过引用传递的参数。
如果完全匹配不存在, binder 将尝试强制指定在数组中指定的 types 参数类型,以便选择匹配项。
binder如果无法选择匹配项,则null返回。
以下 BindingFlags 筛选器标志可用于定义要在搜索中包含哪些构造函数:
您必须指定
BindingFlags.Instance或BindingFlags.Static才能获得返回结果。指定
BindingFlags.Public在搜索中包含公共构造函数。指定
BindingFlags.NonPublic在搜索中包含非公共构造函数(即专用构造函数、内部构造函数和受保护的构造函数)。
有关详细信息,请参阅 System.Reflection.BindingFlags。
此方法实现 GetConstructor。