CustomAttributeExtensions.IsDefined 方法

定義

指出是否將自訂屬性套用至項目。Indicates whether custom attributes are applied to an element.

多載

IsDefined(MemberInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的成員,以及選擇性地套用到其上階。Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors.

IsDefined(Assembly, Type)

指出是否將所指定型別的自訂屬性套用至指定的組件。Indicates whether custom attributes of a specified type are applied to a specified assembly.

IsDefined(MemberInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的成員。Indicates whether custom attributes of a specified type are applied to a specified member.

IsDefined(Module, Type)

指出是否將所指定型別的自訂屬性套用至指定的模組。Indicates whether custom attributes of a specified type are applied to a specified module.

IsDefined(ParameterInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的參數。Indicates whether custom attributes of a specified type are applied to a specified parameter.

IsDefined(ParameterInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的參數,以及選擇性地套用到其上階。Indicates whether custom attributes of a specified type are applied to a specified parameter, and, optionally, applied to its ancestors.

IsDefined(MemberInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的成員,以及選擇性地套用到其上階。Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors.

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

要檢查的成員。The member to inspect.

attributeType
Type

要搜尋之屬性的型別。The type of the attribute to search for.

inherit
Boolean

true 表示檢查element的祖系,否則為falsetrue to inspect the ancestors of element; otherwise, false.

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 falsetrue if an attribute of the specified type is applied to element; otherwise, false.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

IsDefined(Assembly, Type)

指出是否將所指定型別的自訂屬性套用至指定的組件。Indicates whether custom attributes of a specified type are applied to a specified assembly.

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

要檢查的組件。The assembly to inspect.

attributeType
Type

要搜尋之屬性的型別。The type of the attribute to search for.

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 falsetrue if an attribute of the specified type is applied to element; otherwise, false.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

IsDefined(MemberInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的成員。Indicates whether custom attributes of a specified type are applied to a specified member.

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

要檢查的成員。The member to inspect.

attributeType
Type

要搜尋的屬性類型。The type of attribute to search for.

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 falsetrue if an attribute of the specified type is applied to element; otherwise, false.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

element 不是建構函式、方法、屬性、事件、型別或欄位。element is not a constructor, method, property, event, type, or field.

IsDefined(Module, Type)

指出是否將所指定型別的自訂屬性套用至指定的模組。Indicates whether custom attributes of a specified type are applied to a specified module.

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

要檢查的模型。The module to inspect.

attributeType
Type

要搜尋的屬性類型。The type of attribute to search for.

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 falsetrue if an attribute of the specified type is applied to element; otherwise, false.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

IsDefined(ParameterInfo, Type)

指出是否將所指定型別的自訂屬性套用至指定的參數。Indicates whether custom attributes of a specified type are applied to a specified parameter.

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

要檢查的參數。The parameter to inspect.

attributeType
Type

要搜尋的屬性類型。The type of attribute to search for.

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 falsetrue if an attribute of the specified type is applied to element; otherwise, false.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

IsDefined(ParameterInfo, Type, Boolean)

指出指定之型別的自訂屬性是否會套用至指定的參數,以及選擇性地套用到其上階。Indicates whether custom attributes of a specified type are applied to a specified parameter, and, optionally, applied to its ancestors.

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

要檢查的參數。The parameter to inspect.

attributeType
Type

要搜尋的屬性類型。The type of attribute to search for.

inherit
Boolean

true 表示檢查element的祖系,否則為falsetrue to inspect the ancestors of element; otherwise, false.

傳回

如果指定的型別的屬性套用至 element,則為 true,否則為 falsetrue if an attribute of the specified type is applied to element; otherwise, false.

例外狀況

elementattributeTypenullelement or attributeType is null.

attributeType 不是衍生自 AttributeattributeType is not derived from Attribute.

適用於