AttributeUsageAttribute 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定另一個屬性類別的使用方式。 此類別無法獲得繼承。
public ref class AttributeUsageAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)]
public sealed class AttributeUsageAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)]
[System.Serializable]
public sealed class AttributeUsageAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AttributeUsageAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)>]
type AttributeUsageAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)>]
[<System.Serializable>]
type AttributeUsageAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type AttributeUsageAttribute = class
inherit Attribute
Public NotInheritable Class AttributeUsageAttribute
Inherits Attribute
- 繼承
- 屬性
備註
當你定義自己的屬性類別時,可以透過在屬性類別上放置 來 AttributeUsageAttribute 控制它的使用方式。 所指定的屬性類別必須直接或間接源自 Attribute。
屬性類別有位置參數與命名參數。 每個屬性類別的公開建構子定義該類別有效的位置參數序列。 命名參數由屬性類別的非靜態、公開及讀寫欄位或屬性定義。
的 AttributeUsageAttribute 三個性質是透過定義以下參數來設定的:
此位置參數指定該屬性可放置的程式元素。 所有可以放置屬性的元素集合會列在列舉中 AttributeTargets 。 你可以用位元順序的 OR 運算組合多個 AttributeTargets 值,得到所需的有效程式元素組合。
此命名參數指定該屬性是否能對特定程式元素指定多次。
此命名參數指定該屬性是否能由衍生類別及覆寫成員繼承。
建構函式
| 名稱 | Description |
|---|---|
| AttributeUsageAttribute(AttributeTargets) |
初始化類別的新實例 AttributeUsageAttribute ,包含指定的清單 AttributeTargets、值 AllowMultiple 和值 Inherited 。 |
屬性
| 名稱 | Description |
|---|---|
| AllowMultiple |
取得或設定一個布林值,表示是否可以為單一程式元素指定多個該屬性實例。 |
| Inherited |
取得或設定一個 Boolean 值,決定該屬性是否被衍生類別及覆寫成員繼承。 |
| TypeId |
在衍生類別中實作時,取得這個 Attribute的唯一標識碼。 (繼承來源 Attribute) |
| ValidOn |
會獲得一組值,標示該屬性可套用哪些程式元素。 |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
傳回值,這個值表示這個實例是否等於指定的物件。 (繼承來源 Attribute) |
| GetHashCode() |
傳回這個實例的哈希碼。 (繼承來源 Attribute) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| IsDefaultAttribute() |
在衍生類別中覆寫時,指出這個實例的值是否為衍生類別的預設值。 (繼承來源 Attribute) |
| Match(Object) |
在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。 (繼承來源 Attribute) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |
明確介面實作
| 名稱 | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。 (繼承來源 Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
擷取 物件的型別資訊,可用來取得介面的類型資訊。 (繼承來源 Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
擷取物件提供的類型資訊介面數目 (0 或 1)。 (繼承來源 Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
提供物件所公開屬性和方法的存取權。 (繼承來源 Attribute) |