CustomAttributeExtensions.GetCustomAttributes 方法

定義

擷取一組套用在指定元素上的自訂屬性。

多載

名稱 Description
GetCustomAttributes(ParameterInfo, Type, Boolean)

擷取一組指定類型的自訂屬性,套用於指定參數,並可選擇性檢查該參數的祖先。

GetCustomAttributes(MemberInfo, Type, Boolean)

擷取一組指定類型的自訂屬性,套用於指定成員,並可選擇性檢查該成員的祖先。

GetCustomAttributes(ParameterInfo, Type)

擷取一組指定類型的自訂屬性,這些屬性套用於指定參數。

GetCustomAttributes(ParameterInfo, Boolean)

擷取一套套用於指定參數的自訂屬性,並可選擇性地檢查該參數的祖先屬性。

GetCustomAttributes(Module, Type)

擷取一組指定型別的自訂屬性,這些屬性套用到指定模組上。

GetCustomAttributes(MemberInfo, Type)

擷取一組指定類型的自訂屬性,套用到指定成員。

GetCustomAttributes(MemberInfo, Boolean)

擷取一套套用於指定成員的自訂屬性,並可選擇性地檢查該成員的祖先。

GetCustomAttributes(Assembly, Type)

擷取套用至指定元件之指定型別的自定義屬性集合。

GetCustomAttributes(ParameterInfo)

擷取一套套用於指定參數的自訂屬性集合。

GetCustomAttributes(Module)

擷取一套套用到指定模組的自訂屬性集合。

GetCustomAttributes(MemberInfo)

擷取一套套用於指定成員的自訂屬性集合。

GetCustomAttributes(Assembly)

擷取套用至指定元件之自定義屬性的集合。

GetCustomAttributes<T>(ParameterInfo, Boolean)

擷取一組指定類型的自訂屬性,套用於指定參數,並可選擇性檢查該參數的祖先。

GetCustomAttributes<T>(MemberInfo, Boolean)

擷取一組指定類型的自訂屬性,套用於指定成員,並可選擇性檢查該成員的祖先。

GetCustomAttributes<T>(ParameterInfo)

擷取一組指定類型的自訂屬性,這些屬性套用於指定參數。

GetCustomAttributes<T>(MemberInfo)

擷取一組指定類型的自訂屬性,套用到指定成員。

GetCustomAttributes<T>(Assembly)

擷取套用至指定元件之指定型別的自定義屬性集合。

GetCustomAttributes<T>(Module)

擷取一組指定型別的自訂屬性,這些屬性套用到指定模組上。

GetCustomAttributes(ParameterInfo, Type, Boolean)

擷取一組指定類型的自訂屬性,套用於指定參數,並可選擇性檢查該參數的祖先。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, Type ^ attributeType, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.ParameterInfo element, Type attributeType, bool inherit);
static member GetCustomAttributes : System.Reflection.ParameterInfo * Type * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo, attributeType As Type, inherit As Boolean) As IEnumerable(Of Attribute)

參數

element
ParameterInfo

要檢查的參數。

attributeType
Type

要搜尋的屬性類型。

inherit
Boolean

true以檢視祖element先;否則,。 false

傳回

一組套用於 element 和 的 attributeType自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementattributeTypenull

attributeType 並非由 推導而來 Attribute

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(MemberInfo, Type, Boolean)

擷取一組指定類型的自訂屬性,套用於指定成員,並可選擇性檢查該成員的祖先。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, Type ^ attributeType, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.MemberInfo element, Type attributeType, bool inherit);
static member GetCustomAttributes : System.Reflection.MemberInfo * Type * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo, attributeType As Type, inherit As Boolean) As IEnumerable(Of Attribute)

參數

element
MemberInfo

要檢查的成員。

attributeType
Type

要搜尋的屬性類型。

inherit
Boolean

true以檢視祖element先;否則,。 false

傳回

一組套用於 element 和 的 attributeType自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementattributeTypenull

attributeType 並非由 推導而來 Attribute

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(ParameterInfo, Type)

擷取一組指定類型的自訂屬性,這些屬性套用於指定參數。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.ParameterInfo element, Type attributeType);
static member GetCustomAttributes : System.Reflection.ParameterInfo * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo, attributeType As Type) As IEnumerable(Of Attribute)

參數

element
ParameterInfo

要檢查的參數。

attributeType
Type

要搜尋的屬性類型。

傳回

一組套用於 element 和 的 attributeType自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementattributeTypenull

attributeType 並非由 推導而來 Attribute

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(ParameterInfo, Boolean)

擷取一套套用於指定參數的自訂屬性,並可選擇性地檢查該參數的祖先屬性。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.ParameterInfo element, bool inherit);
static member GetCustomAttributes : System.Reflection.ParameterInfo * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo, inherit As Boolean) As IEnumerable(Of Attribute)

參數

element
ParameterInfo

要檢查的參數。

inherit
Boolean

true以檢視祖element先;否則,。 false

傳回

一套套用於 element的自訂屬性集合,若不存在則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(Module, Type)

擷取一組指定型別的自訂屬性,這些屬性套用到指定模組上。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Module ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.Module element, Type attributeType);
static member GetCustomAttributes : System.Reflection.Module * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Module, attributeType As Type) As IEnumerable(Of Attribute)

參數

element
Module

要檢查的模組。

attributeType
Type

要搜尋的屬性類型。

傳回

一組套用於 element 和 的 attributeType自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementattributeTypenull

attributeType 並非由 推導而來 Attribute

適用於

GetCustomAttributes(MemberInfo, Type)

擷取一組指定類型的自訂屬性,套用到指定成員。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.MemberInfo element, Type attributeType);
static member GetCustomAttributes : System.Reflection.MemberInfo * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo, attributeType As Type) As IEnumerable(Of Attribute)

參數

element
MemberInfo

要檢查的成員。

attributeType
Type

要搜尋的屬性類型。

傳回

一組套用於 element 和 的 attributeType自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementattributeTypenull

attributeType 並非由 推導而來 Attribute

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(MemberInfo, Boolean)

擷取一套套用於指定成員的自訂屬性,並可選擇性地檢查該成員的祖先。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.MemberInfo element, bool inherit);
static member GetCustomAttributes : System.Reflection.MemberInfo * bool -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo, inherit As Boolean) As IEnumerable(Of Attribute)

參數

element
MemberInfo

要檢查的成員。

inherit
Boolean

true以檢視祖element先;否則,。 false

傳回

一套套用 element 到符合指定條件的自訂屬性集合,若沒有此類屬性則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(Assembly, Type)

擷取套用至指定元件之指定型別的自定義屬性集合。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Assembly ^ element, Type ^ attributeType);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.Assembly element, Type attributeType);
static member GetCustomAttributes : System.Reflection.Assembly * Type -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Assembly, attributeType As Type) As IEnumerable(Of Attribute)

參數

element
Assembly

要檢查的組裝。

attributeType
Type

要搜尋的屬性類型。

傳回

一組套用於 element 和 的 attributeType自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementattributeTypenull

attributeType 並非由 推導而來 Attribute

適用於

GetCustomAttributes(ParameterInfo)

擷取一套套用於指定參數的自訂屬性集合。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.ParameterInfo element);
static member GetCustomAttributes : System.Reflection.ParameterInfo -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As ParameterInfo) As IEnumerable(Of Attribute)

參數

element
ParameterInfo

要檢查的參數。

傳回

一套套用於 element的自訂屬性集合,若不存在則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(Module)

擷取一套套用到指定模組的自訂屬性集合。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Module ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.Module element);
static member GetCustomAttributes : System.Reflection.Module -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Module) As IEnumerable(Of Attribute)

參數

element
Module

要檢查的模組。

傳回

一套套用於 element的自訂屬性集合,若不存在則為空集合。

例外狀況

elementnull

適用於

GetCustomAttributes(MemberInfo)

擷取一套套用於指定成員的自訂屬性集合。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.MemberInfo element);
static member GetCustomAttributes : System.Reflection.MemberInfo -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As MemberInfo) As IEnumerable(Of Attribute)

參數

element
MemberInfo

要檢查的成員。

傳回

一套套用於 element的自訂屬性集合,若不存在則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes(Assembly)

擷取套用至指定元件之自定義屬性的集合。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<Attribute ^> ^ GetCustomAttributes(System::Reflection::Assembly ^ element);
public static System.Collections.Generic.IEnumerable<Attribute> GetCustomAttributes(this System.Reflection.Assembly element);
static member GetCustomAttributes : System.Reflection.Assembly -> seq<Attribute>
<Extension()>
Public Function GetCustomAttributes (element As Assembly) As IEnumerable(Of Attribute)

參數

element
Assembly

要檢查的組裝。

傳回

一套套用於 element的自訂屬性集合,若不存在則為空集合。

例外狀況

elementnull

適用於

GetCustomAttributes<T>(ParameterInfo, Boolean)

擷取一組指定類型的自訂屬性,套用於指定參數,並可選擇性檢查該參數的祖先。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T>(this System.Reflection.ParameterInfo element, bool inherit) where T : Attribute;
static member GetCustomAttributes : System.Reflection.ParameterInfo * bool -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As ParameterInfo, inherit As Boolean) As IEnumerable(Of T)

類型參數

T

要搜尋的屬性類型。

參數

element
ParameterInfo

要檢查的參數。

inherit
Boolean

true以檢視祖element先;否則,。 false

傳回

一組套用於 element 和 的 T自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes<T>(MemberInfo, Boolean)

擷取一組指定類型的自訂屬性,套用於指定成員,並可選擇性檢查該成員的祖先。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element, bool inherit);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T>(this System.Reflection.MemberInfo element, bool inherit) where T : Attribute;
static member GetCustomAttributes : System.Reflection.MemberInfo * bool -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As MemberInfo, inherit As Boolean) As IEnumerable(Of T)

類型參數

T

要搜尋的屬性類型。

參數

element
MemberInfo

要檢查的成員。

inherit
Boolean

true以檢視祖element先;否則,。 false

傳回

一組套用於 element 和 的 T自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes<T>(ParameterInfo)

擷取一組指定類型的自訂屬性,這些屬性套用於指定參數。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::ParameterInfo ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T>(this System.Reflection.ParameterInfo element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.ParameterInfo -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As ParameterInfo) As IEnumerable(Of T)

類型參數

T

要搜尋的屬性類型。

參數

element
ParameterInfo

要檢查的參數。

傳回

一組套用於 element 和 的 T自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes<T>(MemberInfo)

擷取一組指定類型的自訂屬性,套用到指定成員。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::MemberInfo ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T>(this System.Reflection.MemberInfo element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.MemberInfo -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As MemberInfo) As IEnumerable(Of T)

類型參數

T

要搜尋的屬性類型。

參數

element
MemberInfo

要檢查的成員。

傳回

一組套用於 element 和 的 T自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementnull

element 不是建構子、方法、屬性、事件、類型或欄位。

自訂屬性型別無法載入。

適用於

GetCustomAttributes<T>(Assembly)

擷取套用至指定元件之指定型別的自定義屬性集合。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::Assembly ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T>(this System.Reflection.Assembly element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.Assembly -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As Assembly) As IEnumerable(Of T)

類型參數

T

要搜尋的屬性類型。

參數

element
Assembly

要檢查的組裝。

傳回

一組套用於 element 和 的 T自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementnull

適用於

GetCustomAttributes<T>(Module)

擷取一組指定型別的自訂屬性,這些屬性套用到指定模組上。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::IEnumerable<T> ^ GetCustomAttributes(System::Reflection::Module ^ element);
public static System.Collections.Generic.IEnumerable<T> GetCustomAttributes<T>(this System.Reflection.Module element) where T : Attribute;
static member GetCustomAttributes : System.Reflection.Module -> seq<'T (requires 'T :> Attribute)> (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttributes(Of T As Attribute) (element As Module) As IEnumerable(Of T)

類型參數

T

要搜尋的屬性類型。

參數

element
Module

要檢查的模組。

傳回

一組套用於 element 和 的 T自訂屬性集合,若不存在這些屬性,則為空集合。

例外狀況

elementnull

適用於