Type.GetPropertyImpl(String, BindingFlags, Binder, Type, Type[], ParameterModifier[]) 方法

定義

在衍生類別中覆寫時,使用指定的繫結條件約束搜尋指定的屬性,而該屬性的參數符合指定的引數類型和修飾詞的建構函式。When overridden in a derived class, searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints.

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);
protected abstract System.Reflection.PropertyInfo GetPropertyImpl (string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type returnType, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetPropertyImpl : string * System.Reflection.BindingFlags * System.Reflection.Binder * Type * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.PropertyInfo

參數

name
String

字串,包含要取得的屬性名稱。The string containing the name of the property to get.

bindingAttr
BindingFlags

列舉值的位元組合,用來指定搜尋的執行方式。A bitwise combination of the enumeration values that specify how the search is conducted.

-或--or- 要傳回 nullDefaultDefault to return null.

binder
Binder

定義一組屬性並啟用繫結的物件,可包含多載成員的選擇、引數類型的強制,以及透過反映的成員引動過程。An object that defines a set of properties and enables binding, which can involve selection of an overloaded member, coercion of argument types, and invocation of a member through reflection.

-或--or- Null 參考 (在 Visual Basic 中為 Nothing),可使用 DefaultBinderA null reference (Nothing in Visual Basic), to use the DefaultBinder.

returnType
Type

屬性的傳回類型。The return type of the property.

types
Type[]

Type 物件的陣列,代表所要取得之索引屬性的參數數目、順序和類型。An array of Type objects representing the number, order, and type of the parameters for the indexed property to get.

-或--or- 用以取得未編製索引的屬性之 Type 類型的空陣列 (也就是,Type[] types = new Type[0])。An empty array of the type Type (that is, Type[] types = new Type[0]) to get a property that is not indexed.

modifiers
ParameterModifier[]

ParameterModifier 物件的陣列,代表在 types 陣列中與對應項目關聯的屬性。An array of ParameterModifier objects representing the attributes associated with the corresponding element in the types array. 預設的繫結器不會處理這個參數。The default binder does not process this parameter.

傳回

代表符合指定之需求屬性的物件 (如有找到);否則為 nullAn object representing the property that matches the specified requirements, if found; otherwise, null.

例外狀況

找到一個以上的屬性,其具有指定名稱,且符合指定繫結條件約束。More than one property is found with the specified name and matching the specified binding constraints.

namenullname is null.

-或--or- typesnulltypes is null.

-或--or- types 的其中一個項目為 nullOne of the elements in types is null.

types 是多維的。types is multidimensional.

-或--or- modifiers 是多維的。modifiers is multidimensional.

-或--or- typesmodifiers 的長度不同。types and modifiers do not have the same length.

備註

雖然預設的系結器不會處理 ParameterModifiermodifiers 參數),但您可以使用抽象的 System.Reflection.Binder 類別來撰寫會處理 modifiers的自訂系結器。Although the default binder does not process ParameterModifier (the modifiers parameter), you can use the abstract System.Reflection.Binder class to write a custom binder that does process modifiers. 只有在透過 COM Interop 呼叫時,才會使用 ParameterModifier,而且只會處理以傳址方式傳遞的參數。ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.

下列 BindingFlags 篩選旗標可以用來定義要包含在搜尋中的屬性:The following BindingFlags filter flags can be used to define which properties to include in the search:

  • 您必須指定 BindingFlags.InstanceBindingFlags.Static,才能取得傳回。You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.

  • 指定要在搜尋中包含公用屬性 BindingFlags.PublicSpecify BindingFlags.Public to include public properties in the search.

  • 指定要在搜尋中包含非公用屬性(也就是私用、內部和受保護的屬性) BindingFlags.NonPublicSpecify BindingFlags.NonPublic to include non-public properties (that is, private, internal, and protected properties) in the search.

  • 指定 BindingFlags.FlattenHierarchy 在階層中包含 publicprotected 靜態成員;不包含繼承類別中 private 的靜態成員。Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.

下列 BindingFlags 的修飾詞旗標可以用來變更搜尋的運作方式:The following BindingFlags modifier flags can be used to change how the search works:

  • BindingFlags.IgnoreCase 以忽略 name的大小寫。BindingFlags.IgnoreCase to ignore the case of name.

  • BindingFlags.DeclaredOnly 只搜尋 Type上宣告的屬性,而不是直接繼承的屬性。BindingFlags.DeclaredOnly to search only the properties declared on the Type, not properties that were simply inherited.

如需詳細資訊,請參閱 System.Reflection.BindingFlagsSee System.Reflection.BindingFlags for more information.

適用於

另請參閱