AttributeUsageAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.Class, Inherited:=True)> _ Public NotInheritable Class AttributeUsageAttribute Inherits Attribute
[SerializableAttribute] [ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets.Class, Inherited=true)] public sealed class AttributeUsageAttribute : Attribute
[SerializableAttribute] [ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets::Class, Inherited=true)] public ref class AttributeUsageAttribute sealed : public Attribute

独自の属性クラスを定義している場合、その属性クラスに AttributeUsageAttribute を配置することによって、そのクラスの使用方法を制御できます。制御対象とする属性クラスは、Attribute から直接または間接に派生したものである必要があります。
属性クラスには、位置指定パラメータと名前付きパラメータがあります。属性クラスの各パブリック コンストラクタは、そのクラスの位置指定パラメータについて、有効なシーケンスを定義します。名前付きパラメータは、属性クラスの非静的で、パブリックで、読み取り/書き込み可能なフィールドまたはプロパティで定義されます。
AttributeUsageAttribute の 3 つのプロパティは、次のパラメータを定義することによって設定します。
-
ValidOn
この位置指定パラメータは、制御対象とする属性を配置できるプログラム要素を指定します。属性を配置できるすべての要素は、AttributeTargets 列挙子でリストされます。ビット単位の OR 演算を使用して複数の AttributeTargets 値を組み合わせて、有効なプログラム要素を適宜組み合わせて取得できます。
-
AllowMultiple
この名前付きパラメータは、制御対象とする属性を特定のプログラム要素に対して複数回指定できるかどうかを指定します。
この名前付きパラメータは、派生クラスおよびオーバーライドするメンバが、制御対象とする属性を継承できるかどうかを指定します。

System.Attribute
System.AttributeUsageAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


AttributeUsageAttribute コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)


ビット単位の OR 演算を使用して複数の AttributeTargets 値を組み合わせて、有効なプログラム要素を適宜組み合わせて取得できます。
既定のプロパティ値については、ValidOn、AllowMultiple、Inherited の各プロパティのトピックを参照してください。

DispId 属性の定義には、複数の AttributeTargets 値を組み合わせるビット単位の OR 演算の使用方法が示されています。
Namespace System.Runtime.InteropServices <AttributeUsage(AttributeTargets.Method _ Or AttributeTargets.Field _ Or AttributeTargets.Property)> _ Public Class DispIdAttribute Inherits System.Attribute Public Sub New(value As Integer) ' . . . End Sub Public ReadOnly Property Value() As Integer Get ' . . . Return 0 End Get End Property End Class End Namespace
namespace System.Runtime.InteropServices { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] public class DispIdAttribute: System.Attribute { public DispIdAttribute(int value) { // . . . } public int Value { get { // . . . return 0; } } } }
namespace InteropServices { [AttributeUsage(AttributeTargets::Method| AttributeTargets::Field| AttributeTargets::Property) ] public ref class DispIdAttribute: public Attribute { public: DispIdAttribute( int value ) { // . . . } property int Value { int get() { // . . . return 0; } } }; }
/** @attribute AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property) */ public class DispIdAttribute extends System.Attribute { public DispIdAttribute(int value) { //. . . } //DispIdAttribute /** @property */ public int get_Value() { //. . . return 0; }//get_Value } //DispIdAttribute

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


AttributeUsageAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() ![]() ![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |
![]() | ValidOn | 制御対象とする属性を適用できるプログラム要素を識別する一連の値を取得します。 |

AttributeUsageAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

AttributeUsageAttribute メンバ
別の属性クラスの使用方法を指定します。このクラスは継承できません。
AttributeUsageAttribute データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | AttributeUsageAttribute | AttributeTargets、AllowMultiple 値、および Inherited 値の指定リストを使用して、AttributeUsageAttribute クラスの新しいインスタンスを初期化します。 |

名前 | 説明 | |
---|---|---|
![]() ![]() ![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |
![]() | ValidOn | 制御対象とする属性を適用できるプログラム要素を識別する一連の値を取得します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

- AttributeUsageAttributeのページへのリンク