ProvidePropertyAttribute クラス

定義

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

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

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

[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;
    // Provides the Get portion of MyProperty. 
    public CultureInfo GetMyProperty(Control myControl) =>
        // Insert code here.
        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) => 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を実装する必要があります。 その結果、新しいプロパティはコンテナー内の他のコンポーネントで使用できます。

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

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

コンストラクター

名前 説明
ProvidePropertyAttribute(String, String)

プロパティの名前とそのレシーバーの型を使用して、 ProvidePropertyAttribute クラスの新しいインスタンスを初期化します。

ProvidePropertyAttribute(String, Type)

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

プロパティ

名前 説明
PropertyName

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

ReceiverTypeName

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

TypeId

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

メソッド

名前 説明
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)

適用対象