Type.GetPropertyImpl 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在派生类中重写时,使用指定的绑定约束搜索其参数与指定参数类型和修饰符匹配的指定属性。
protected:
abstract System::Reflection::PropertyInfo ^ GetPropertyImpl(System::String ^ name, System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, Type ^ returnType, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)]
protected abstract System.Reflection.PropertyInfo? GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, Type? returnType, Type[]? types, System.Reflection.ParameterModifier[]? modifiers);
protected abstract System.Reflection.PropertyInfo GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type returnType, Type[] types, System.Reflection.ParameterModifier[] modifiers);
protected abstract System.Reflection.PropertyInfo? GetPropertyImpl(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, Type? returnType, Type[]? types, System.Reflection.ParameterModifier[]? modifiers);
[<System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicProperties | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)>]
abstract member GetPropertyImpl : string * System.Reflection.BindingFlags * System.Reflection.Binder * Type * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.PropertyInfo
abstract member GetPropertyImpl : string * System.Reflection.BindingFlags * System.Reflection.Binder * Type * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.PropertyInfo
Protected MustOverride Function GetPropertyImpl (name As String, bindingAttr As BindingFlags, binder As Binder, returnType As Type, types As Type(), modifiers As ParameterModifier()) As PropertyInfo
参数
- name
- String
包含要获取的属性的名称的字符串。
- binder
- Binder
一个对象,该对象定义一组属性并启用绑定,这可能涉及选择重载成员、强制参数类型以及通过反射调用成员。
-或-
null 引用(Visual Basic 中的 Nothing),以使用 DefaultBinder。
- returnType
- Type
属性的返回类型。
- types
- Type[]
表示要获取的索引属性的参数数、顺序和类型的对象的数组 Type 。
-或-
类型(即 Type[] types = new Type[0])的 Type 空数组,用于获取未编制索引的属性。
- modifiers
- ParameterModifier[]
表示与数组中ParameterModifier相应元素关联的属性的对象数组types。 默认绑定器不处理此参数。
返回
一个对象,表示符合指定要求的属性(如果找到);否则,为 null.
- 属性
例外
找到具有指定名称并匹配指定绑定约束的多个属性。
注解
尽管默认联编程序不处理 ParameterModifier ( modifiers 参数),但可以使用抽象 System.Reflection.Binder 类编写一个处理自定义 modifiers联编程序。
ParameterModifier 仅在通过 COM 互作调用时使用,并且仅处理通过引用传递的参数。
以下 BindingFlags 筛选器标志可用于定义要在搜索中包含哪些属性:
您必须指定
BindingFlags.Instance或BindingFlags.Static才能获得返回结果。指定
BindingFlags.Public在搜索中包含公共属性。指定
BindingFlags.NonPublic在搜索中包含非公共属性(即专用属性、内部属性和受保护属性)。指定
BindingFlags.FlattenHierarchy为包含public层次结构中的静态成员和protected静态成员;private不包括继承类中的静态成员。
以下 BindingFlags 修饰符标志可用于更改搜索的工作原理:
BindingFlags.IgnoreCase用于忽略name的大小写。BindingFlags.DeclaredOnly仅搜索在Type中声明的属性,而不是继承的属性。
有关详细信息,请参阅 System.Reflection.BindingFlags。