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

ProvidePropertyAttribute クラス

IExtenderProvider の実装元が他のコンポーネントに提供するプロパティの名前を指定します。このクラスは継承できません。

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

<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple:=True)> _
Public NotInheritable Class
 ProvidePropertyAttribute
    Inherits Attribute
Dim instance As ProvidePropertyAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true)]
 
public sealed class ProvidePropertyAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple=true)]
 
public ref class ProvidePropertyAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true)
 */ 
public final class ProvidePropertyAttribute
 extends Attribute
AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true)
 
public final class ProvidePropertyAttribute
 extends Attribute
解説解説

この属性でクラスをマークする場合は、指定した名前でエクステンダ プロパティを作成するようにコード ジェネレータに指示します。マークされたクラスは、IExtenderProvider を実装する必要があります。その結果、新しいプロパティをコンテナ内の他のコンポーネントで使用できるようになります。

マークされたクラスの内部で、Get <name> メソッドと Set <name> メソッドを実装する必要があります。たとえば、[ProvideProperty("PropertyName")] でクラスをマークした場合は、GetPropertyName メソッドと SetPropertyName メソッドを実装する必要があります。新しいプロパティをエクステンダ プロパティとして指定するには、IExtenderProvider から実装し、CanExtend メソッドも実装する必要があります。

詳細については、属性の概要、属性を使用したメタデータの拡張 の各トピックを参照してください。

使用例使用例

MyClass を ProvidePropertyAttribute でマークし、GetMyProperty メソッドと SetMyProperty メソッドから MyProperty という名前のプロパティを作成するようにコンパイラに指示する例を次に示します。

<ProvideProperty("MyProperty", GetType(Control))>
 _
Public Class SampleClass
    Implements IExtenderProvider
    Protected ciMine As CultureInfo = Nothing

    ' Provides the Get portion of MyProperty. 
    Public Function GetMyProperty(myControl
 As Control) As CultureInfo
        ' Insert code here.
        Return ciMine
    End Function 'GetMyProperty

    ' Provides the Set portion of MyProperty.
    Public Sub SetMyProperty(myControl As
 Control, value As String)
        ' Insert code here.
    End Sub 'SetMyProperty

    ' When you inherit from IExtenderProvider, you must implement the
 
    ' CanExtend method. 
    Public Function CanExtend(target As
 [Object]) As Boolean Implements
 IExtenderProvider.CanExtend
        Return TypeOf target Is
 Control
    End Function 'CanExtend

    ' Insert additional code here.

End Class
[ProvideProperty("MyProperty", typeof(Control))]
public class MyClass : IExtenderProvider {
    protected CultureInfo ciMine = null;
    // Provides the Get portion of MyProperty. 
    public CultureInfo GetMyProperty(Control myControl) {
        // Insert code here.
        return ciMine;
    }
    
    // Provides the Set portion of MyProperty.
    public void SetMyProperty(Control myControl,
 string value) {
        // Insert code here.
    }
    
    /* When you inherit from IExtenderProvider, you must implement the 
     * CanExtend method. */
    public bool CanExtend(Object target) {
        return(target is Control);
    }
    
    // Insert additional code here.
 }
[ProvideProperty("MyProperty",Control::typeid)]
public ref class MyClass: public
 IExtenderProvider
{
protected:
   CultureInfo^ ciMine;

public:
   // Provides the Get portion of MyProperty. 
   CultureInfo^ GetMyProperty( Control^ myControl )
   {
      // Insert code here.
      return ciMine;
   }

   // Provides the Set portion of MyProperty.
   void SetMyProperty( Control^ myControl, String^ value )
   {
      // Insert code here.
   }

   /* When you inherit from IExtenderProvider, you must implement the 
        * CanExtend method. */
   virtual bool CanExtend( Object^ target )
   {
      return dynamic_cast<Control^>(target) != nullptr;
   }
   // Insert additional code here.
};
public class MyClass implements IExtenderProvider
{
    protected CultureInfo ciMine = null;

    // Provides the Get portion of MyProperty. 
    public CultureInfo GetMyProperty(Control myControl)
    {
        // Insert code here.
        return ciMine;
    } //GetMyProperty

    // Provides the Set portion of MyProperty.
    public void SetMyProperty(Control myControl,
 String value)
    {
        // Insert code here.
    } //SetMyProperty

    /*  When you inherit from IExtenderProvider, you must implement the 
     *   CanExtend method. 
     */
    public boolean CanExtend(Object target)
    {
        return target instanceof Control;
    } //CanExtend
    
    // Insert additional code here.

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

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

プロパティの名前とそのプロパティを受け取る側の型を指定して、ProvidePropertyAttribute クラスの新しいインスタンスを初期化します。

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

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

Dim instance As New ProvidePropertyAttribute(propertyName,
 receiverTypeName)
public ProvidePropertyAttribute (
    string propertyName,
    string receiverTypeName
)
public:
ProvidePropertyAttribute (
    String^ propertyName, 
    String^ receiverTypeName
)
public ProvidePropertyAttribute (
    String propertyName, 
    String receiverTypeName
)
public function ProvidePropertyAttribute (
    propertyName : String, 
    receiverTypeName : String
)

パラメータ

propertyName

指定した型のオブジェクトに拡張するプロパティの名前。

receiverTypeName

このプロパティが拡張できるデータ型の名前。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ProvidePropertyAttribute クラス
ProvidePropertyAttribute メンバ
System.ComponentModel 名前空間

ProvidePropertyAttribute コンストラクタ (String, Type)

プロパティの名前とその Type を指定して、ProvidePropertyAttribute クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    propertyName As String, _
    receiverType As Type _
)
Dim propertyName As String
Dim receiverType As Type

Dim instance As New ProvidePropertyAttribute(propertyName,
 receiverType)
public ProvidePropertyAttribute (
    string propertyName,
    Type receiverType
)
public:
ProvidePropertyAttribute (
    String^ propertyName, 
    Type^ receiverType
)
public ProvidePropertyAttribute (
    String propertyName, 
    Type receiverType
)
public function ProvidePropertyAttribute (
    propertyName : String, 
    receiverType : Type
)

パラメータ

propertyName

指定した型のオブジェクトに拡張するプロパティの名前。

receiverType

プロパティを受け取ることができるオブジェクトのデータ型の Type。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ProvidePropertyAttribute クラス
ProvidePropertyAttribute メンバ
System.ComponentModel 名前空間

ProvidePropertyAttribute コンストラクタ

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

名前 説明
ProvidePropertyAttribute (String, String) プロパティの名前とそのプロパティを受け取る側の型を指定して、ProvidePropertyAttribute クラスの新しいインスタンスを初期化します。
ProvidePropertyAttribute (String, Type) プロパティの名前とその Type を指定して、ProvidePropertyAttribute クラスの新しいインスタンスを初期化します。
参照参照

関連項目

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

ProvidePropertyAttribute プロパティ


ProvidePropertyAttribute メソッド


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

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

関連項目

ProvidePropertyAttribute クラス
System.ComponentModel 名前空間

ProvidePropertyAttribute メンバ

IExtenderProvider の実装元が他のコンポーネントに提供するプロパティの名前を指定します。このクラスは継承できません。

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


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

関連項目

ProvidePropertyAttribute クラス
System.ComponentModel 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「ProvidePropertyAttribute」の関連用語

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

   

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



ProvidePropertyAttributeのページの著作権

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

©2026 GRAS Group, Inc.RSS