Type.GetPropertyImpl 方法

定義

在衍生類別中覆寫時,使用指定的繫結條件約束搜尋指定的屬性,而該屬性的參數符合指定的引數類型和修飾詞的建構函式。

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);
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
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

字串,包含要取得的屬性名稱。

bindingAttr
BindingFlags

列舉值的位元組合,用來指定搜尋的執行方式。

-或-

要傳回 nullDefault

binder
Binder

定義一組屬性並啟用繫結的物件,可包含多載成員的選擇、引數類型的強制,以及透過反映的成員引動過程。

-或-

Null 參考 (在 Visual Basic 中為Nothing ),可使用 DefaultBinder

returnType
Type

屬性的傳回類型。

types
Type[]

Type 物件的陣列,代表所要取得之索引屬性的參數數目、順序和類型。

-或-

用以取得未編製索引的屬性之 Type 類型的空陣列 (也就是,Type[] types = new Type[0])。

modifiers
ParameterModifier[]

ParameterModifier 物件的陣列,代表在 types 陣列中與對應項目關聯的屬性。 預設的繫結器不會處理這個參數。

傳回

代表符合指定之需求屬性的物件 (如有找到);否則為 null

例外狀況

找到一個以上的屬性,其具有指定名稱,且符合指定繫結條件約束。

namenull

-或-

typesnull

-或-

types 的其中一個項目為 null

types 是多維的。

-或-

modifiers 是多維的。

-或-

typesmodifiers 的長度不同。

備註

雖然預設系結器不會處理 ParameterModifier 參數 (modifiers) ,但您可以使用抽象 System.Reflection.Binder 類來撰寫會處理 modifiers 的自訂系結器。 ParameterModifier 只有在透過 COM Interop 呼叫時,才會使用 ,而且只會處理以傳址方式傳遞的參數。

下列 BindingFlags 篩選旗標可用來定義要包含在搜尋中的屬性:

  • 您必須指定 BindingFlags.InstanceBindingFlags.Static ,才能取得傳回。

  • 指定 BindingFlags.Public 以在搜尋中包含公用屬性。

  • 指定 BindingFlags.NonPublic 在搜尋中包含非公用屬性 (,也就是私人、內部和受保護的屬性) 。

  • 指定要 BindingFlags.FlattenHierarchypublic 階層中包含和 protected 靜態成員; private 繼承類別中的靜態成員不包含在內。

下列 BindingFlags 修飾詞旗標可用來變更搜尋的運作方式:

  • BindingFlags.IgnoreCase 忽略 的大小 name 寫。

  • BindingFlags.DeclaredOnly 只搜尋 在 上 Type 宣告的屬性,而不是只繼承的屬性。

如需相關資訊,請參閱 System.Reflection.BindingFlags

適用於

另請參閱