AttributeProviderAttributeとは? わかりやすく解説

AttributeProviderAttribute クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

属性のリダイレクトを有効にします。このクラスは継承できません。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Property)> _
Public Class AttributeProviderAttribute
    Inherits Attribute
Dim instance As AttributeProviderAttribute
[AttributeUsageAttribute(AttributeTargets.Property)] 
public class AttributeProviderAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] 
public ref class AttributeProviderAttribute
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property) */ 
public class AttributeProviderAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Property) 
public class AttributeProviderAttribute extends
 Attribute
解説解説

.NET Framework オブジェクト モデルでは、プロパティが意図的にあいまいになるように型指定される場合もあります。たとえば、DataGridView.DataSource プロパティは、object として型指定されます。このように指定されるのは、このプロパティが複数の入力型を受け入れることができるようにするためです。ただし、これにより、プロパティの特性を記述するためにメタデータを追加する共通の場所はなくなります。.NET Framework 全体で、各 DataSource プロパティは、型コンバータ、UI 型エディタ、およびメタデータを必要とするその他のサービスについて同一のメタデータを持つ必要があります。AttributeProviderAttribute は、このような状況を改善します。

この属性がプロパティに設定されると、プロパティ記述子の MemberDescriptor.Attributes コレクションの属性を取得する規則が変わります。通常、プロパティ記述子はローカル属性を収集し、次にこれらをプロパティ型の属性にマージします。この場合、属性は、実際のプロパティ型からではなく、AttributeProviderAttribute から返された型から取得されます。この属性は、DataGridView.DataSource オブジェクトの特定の型が IListSource を指すようにするために DataGridView.DataSource で使用され、データ バインディングを有効にするために、適切なメタデータが IListSource に配置されます。これによって、外部パーティが容易にメタデータをすべてのデータ ソースに追加できます。

AttributeProviderAttribute で宣言された型から取得した属性の優先順位は、プロパティの型属性とプロパティの属性の中間になります。使用できるマージされた属性の完全なセットを、次の一覧に優先順位に従って示します。

使用例使用例

AttributeProviderAttribute を使用して、IListSource という特定の型で DataSource プロパティをマークするコード例を次に示します。コード全体については、「方法 : Windows フォーム コントロールに属性を適用する」を参照してください。

<Category("Data"), _
Description("Indicates the source of data for the control."),
 _
RefreshProperties(RefreshProperties.Repaint), _
AttributeProvider(GetType(IListSource))> _
Public Property DataSource() As
 Object
    Get
        Return Me.dataGridView1.DataSource
    End Get

    Set(ByVal value As Object)
        Me.dataGridView1.DataSource = value
    End Set
End Property
[Category("Data")]
[Description("Indicates the source of data for the control.")]
[RefreshProperties(RefreshProperties.Repaint)]
[AttributeProvider(typeof(IListSource))]
public object DataSource
{
    get
    {
        return this.dataGridView1.DataSource;
    }

    set
    {
        this.dataGridView1.DataSource = value;
    }
}
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.AttributeProviderAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

AttributeProviderAttribute コンストラクタ (String)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

指定した型名を使用して AttributeProviderAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Dim typeName As String

Dim instance As New AttributeProviderAttribute(typeName)
public AttributeProviderAttribute (
    string typeName
)
public:
AttributeProviderAttribute (
    String^ typeName
)
public AttributeProviderAttribute (
    String typeName
)
public function AttributeProviderAttribute
 (
    typeName : String
)

パラメータ

typeName

指定する型の名前。

例外例外
例外の種類条件

ArgumentNullException

typeName が null 参照 (Visual Basic では Nothing) です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AttributeProviderAttribute クラス
AttributeProviderAttribute メンバ
System.ComponentModel 名前空間
TypeDescriptor
その他の技術情報
型記述子の概要

AttributeProviderAttribute コンストラクタ (Type)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

指定した型を使用して、AttributeProviderAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Dim type As Type

Dim instance As New AttributeProviderAttribute(type)
public AttributeProviderAttribute (
    Type type
)
public:
AttributeProviderAttribute (
    Type^ type
)
public AttributeProviderAttribute (
    Type type
)
public function AttributeProviderAttribute
 (
    type : Type
)

パラメータ

type

指定する型。

例外例外
例外の種類条件

ArgumentNullException

type が null 参照 (Visual Basic では Nothing) です。

使用例使用例

AttributeProviderAttribute を使用して、IListSource の特定の型で DataSource プロパティをマークするコード例を次に示します。コード全体については、「方法 : Windows フォーム コントロールに属性を適用する」を参照してください。

<Category("Data"), _
Description("Indicates the source of data for the control."),
 _
RefreshProperties(RefreshProperties.Repaint), _
AttributeProvider(GetType(IListSource))> _
Public Property DataSource() As
 Object
    Get
        Return Me.dataGridView1.DataSource
    End Get

    Set(ByVal value As Object)
        Me.dataGridView1.DataSource = value
    End Set
End Property
[Category("Data")]
[Description("Indicates the source of data for the control.")]
[RefreshProperties(RefreshProperties.Repaint)]
[AttributeProvider(typeof(IListSource))]
public object DataSource
{
    get
    {
        return this.dataGridView1.DataSource;
    }

    set
    {
        this.dataGridView1.DataSource = value;
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AttributeProviderAttribute クラス
AttributeProviderAttribute メンバ
System.ComponentModel 名前空間
TypeDescriptor
その他の技術情報
型記述子の概要

AttributeProviderAttribute コンストラクタ (String, String)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

指定した型名とプロパティ名を使用して、AttributeProviderAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    typeName As String, _
    propertyName As String _
)
Dim typeName As String
Dim propertyName As String

Dim instance As New AttributeProviderAttribute(typeName,
 propertyName)
public AttributeProviderAttribute (
    string typeName,
    string propertyName
)
public:
AttributeProviderAttribute (
    String^ typeName, 
    String^ propertyName
)
public AttributeProviderAttribute (
    String typeName, 
    String propertyName
)
public function AttributeProviderAttribute
 (
    typeName : String, 
    propertyName : String
)

パラメータ

typeName

指定する型の名前。

propertyName

属性を取得するプロパティの名前。

例外例外
例外の種類条件

ArgumentNullException

typeName が null 参照 (Visual Basic では Nothing) です。

ArgumentNullException

propertyName が null 参照 (Visual Basic では Nothing) です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AttributeProviderAttribute クラス
AttributeProviderAttribute メンバ
System.ComponentModel 名前空間
TypeDescriptor
その他の技術情報
型記述子の概要

AttributeProviderAttribute コンストラクタ

AttributeProviderAttribute クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
AttributeProviderAttribute (String) 指定した型名を使用して AttributeProviderAttribute クラスの新しいインスタンスを初期化します。
AttributeProviderAttribute (Type) 指定した型を使用して、AttributeProviderAttribute クラスの新しいインスタンスを初期化します。
AttributeProviderAttribute (String, String) 指定した型名とプロパティ名を使用して、AttributeProviderAttribute クラスの新しいインスタンスを初期化します。
参照参照

関連項目

AttributeProviderAttribute クラス
AttributeProviderAttribute メンバ
System.ComponentModel 名前空間
TypeDescriptor

その他の技術情報

型記述子の概要

AttributeProviderAttribute プロパティ


AttributeProviderAttribute メソッド


パブリック メソッドパブリック メソッド

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

関連項目

AttributeProviderAttribute クラス
System.ComponentModel 名前空間
TypeDescriptor

その他の技術情報

型記述子の概要

AttributeProviderAttribute メンバ

属性のリダイレクトを有効にします。このクラスは継承できません。

AttributeProviderAttribute データ型で公開されるメンバを以下の表に示します。


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

関連項目

AttributeProviderAttribute クラス
System.ComponentModel 名前空間
TypeDescriptor

その他の技術情報

型記述子の概要



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「AttributeProviderAttribute」の関連用語

AttributeProviderAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



AttributeProviderAttributeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS