CustomAttributeExtensions.IsDefined 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指出是否將自訂屬性套用至項目。
IsDefined(MemberInfo, Type, Boolean) |
指出指定之型別的自訂屬性是否會套用至指定的成員,以及選擇性地套用到其上階。 |
IsDefined(Assembly, Type) |
指出是否將所指定型別的自訂屬性套用至指定的組件。 |
IsDefined(MemberInfo, Type) |
指出是否將所指定型別的自訂屬性套用至指定的成員。 |
IsDefined(Module, Type) |
指出是否將所指定型別的自訂屬性套用至指定的模組。 |
IsDefined(ParameterInfo, Type) |
指出是否將所指定型別的自訂屬性套用至指定的參數。 |
IsDefined(ParameterInfo, 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
。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
element
不是建構函式、方法、屬性、事件、型別或欄位。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
指出是否將所指定型別的自訂屬性套用至指定的組件。
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
。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
指出是否將所指定型別的自訂屬性套用至指定的成員。
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
。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
element
不是建構函式、方法、屬性、事件、型別或欄位。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
指出是否將所指定型別的自訂屬性套用至指定的模組。
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
。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
指出是否將所指定型別的自訂屬性套用至指定的參數。
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
。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
指出指定之型別的自訂屬性是否會套用至指定的參數,以及選擇性地套用到其上階。
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
。
例外狀況
element
或 attributeType
為 null
。
attributeType
不是衍生自 Attribute。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |