ProvidePropertyAttribute クラス

定義

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

public ref class ProvidePropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true)]
public sealed class ProvidePropertyAttribute : Attribute
public sealed class ProvidePropertyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true)>]
type ProvidePropertyAttribute = class
    inherit Attribute
type ProvidePropertyAttribute = class
    inherit Attribute
Public NotInheritable Class ProvidePropertyAttribute
Inherits Attribute
継承
ProvidePropertyAttribute
属性

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

[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.
};
[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", 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

    ' 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

注釈

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

マークされたクラス内では、実装とSet<name>メソッドを実装Get<name>する必要があります。 たとえば、[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)

適用対象