CustomAttributeExtensions.IsDefined 方法

定義

指出是否將自訂屬性套用至項目。

多載

IsDefined(MemberInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的成員,以及選擇性地套用到其上階。

IsDefined(Assembly, Type)

指出是否將所指定型別的自訂屬性套用至指定的組件。

IsDefined(MemberInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的成員。

IsDefined(Module, Type)

指出是否將所指定型別的自訂屬性套用至指定的模組。

IsDefined(ParameterInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的參數。

IsDefined(ParameterInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的參數,以及選擇性地套用到其上階。

IsDefined(MemberInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的成員,以及選擇性地套用到其上階。

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

參數

element
MemberInfo

要檢查的成員。

attributeType
Type

要搜尋之屬性的型別。

inherit
Boolean

true 表示檢查element的祖系,否則為false

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 false

例外狀況

elementattributeTypenull

attributeType 不是衍生自 Attribute

element 不是建構函式、方法、屬性、事件、型別或欄位。

適用於

IsDefined(Assembly, Type)

指出是否將所指定型別的自訂屬性套用至指定的組件。

public:
[System::Runtime::CompilerServices::Extension]
 static bool IsDefined(System::Reflection::Assembly ^ element, Type ^ attributeType);
public static bool IsDefined (this System.Reflection.Assembly element, Type attributeType);
static member IsDefined : System.Reflection.Assembly * Type -> bool
<Extension()>
Public Function IsDefined (element As Assembly, attributeType As Type) As Boolean

參數

element
Assembly

要檢查的組件。

attributeType
Type

要搜尋之屬性的型別。

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 false

例外狀況

elementattributeTypenull

attributeType 不是衍生自 Attribute

適用於

IsDefined(MemberInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的成員。

public:
[System::Runtime::CompilerServices::Extension]
 static bool IsDefined(System::Reflection::MemberInfo ^ element, Type ^ attributeType);
public static bool IsDefined (this System.Reflection.MemberInfo element, Type attributeType);
static member IsDefined : System.Reflection.MemberInfo * Type -> bool
<Extension()>
Public Function IsDefined (element As MemberInfo, attributeType As Type) As Boolean

參數

element
MemberInfo

要檢查的成員。

attributeType
Type

要搜尋的屬性類型。

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 false

例外狀況

elementattributeTypenull

attributeType 不是衍生自 Attribute

element 不是建構函式、方法、屬性、事件、型別或欄位。

適用於

IsDefined(Module, Type)

指出是否將所指定型別的自訂屬性套用至指定的模組。

public:
[System::Runtime::CompilerServices::Extension]
 static bool IsDefined(System::Reflection::Module ^ element, Type ^ attributeType);
public static bool IsDefined (this System.Reflection.Module element, Type attributeType);
static member IsDefined : System.Reflection.Module * Type -> bool
<Extension()>
Public Function IsDefined (element As Module, attributeType As Type) As Boolean

參數

element
Module

要檢查的模型。

attributeType
Type

要搜尋的屬性類型。

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 false

例外狀況

elementattributeTypenull

attributeType 不是衍生自 Attribute

適用於

IsDefined(ParameterInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的參數。

public:
[System::Runtime::CompilerServices::Extension]
 static bool IsDefined(System::Reflection::ParameterInfo ^ element, Type ^ attributeType);
public static bool IsDefined (this System.Reflection.ParameterInfo element, Type attributeType);
static member IsDefined : System.Reflection.ParameterInfo * Type -> bool
<Extension()>
Public Function IsDefined (element As ParameterInfo, attributeType As Type) As Boolean

參數

element
ParameterInfo

要檢查的參數。

attributeType
Type

要搜尋的屬性類型。

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 false

例外狀況

elementattributeTypenull

attributeType 不是衍生自 Attribute

適用於

IsDefined(ParameterInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的參數,以及選擇性地套用到其上階。

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

參數

element
ParameterInfo

要檢查的參數。

attributeType
Type

要搜尋的屬性類型。

inherit
Boolean

true 表示檢查element的祖系,否則為false

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 false

例外狀況

elementattributeTypenull

attributeType 不是衍生自 Attribute

適用於