英語で読む

次の方法で共有


ProvidePropertyAttribute クラス

定義

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

C#
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true)]
public sealed class ProvidePropertyAttribute : Attribute
C#
public sealed class ProvidePropertyAttribute : Attribute
継承
ProvidePropertyAttribute
属性

次の例では、 メソッドと ProvidePropertyAttributeSetMyProperty メソッドから 呼び出された MyProperty プロパティを作成するようにコンパイラに指示する を GetMyProperty でマークMyClassします。

C#
[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.
 }

注釈

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

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

詳細については、「属性」を参照してください。

コンストラクター

ProvidePropertyAttribute(String, String)

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

ProvidePropertyAttribute(String, Type)

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

プロパティ

PropertyName

このクラスが提供するプロパティの名前を取得します。

ReceiverTypeName

このプロパティが拡張できるデータ型の名前を取得します。

TypeId

この属性の一意の識別子を取得します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

指定したオブジェクトの値が現在の ProvidePropertyAttribute と等しいかどうかを示す値を返します。

GetHashCode()

このインスタンスのハッシュ コードを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

製品 バージョン
.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 1.1, 2.0, 3.0, 3.5, 4.0, 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 2.0, 2.1