ProvidePropertyAttribute クラス
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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
- 継承
- 属性
次の例では、 メソッドと ProvidePropertyAttributeSetMyProperty
メソッドから 呼び出された MyProperty
プロパティを作成するようにコンパイラに指示する を GetMyProperty
でマーク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する必要があります。 その結果、コンテナー内の他のコンポーネントで新しいプロパティを使用できます。
マークされたクラス内で、name メソッドと Set
<name>> メソッドを実装Get
<する必要があります。 たとえば、[ProvideProperty("PropertyName")] でクラスをマークする場合は、 メソッドと SetPropertyName
メソッドを実装GetPropertyName
する必要があります。 新しいプロパティがエクステンダー プロパティであることを指定するには、 から IExtenderProviderを実装する必要があります。メソッドも実装する CanExtend
必要があります。
詳細については、「属性」を参照してください。
Provide |
プロパティの名前とそのプロパティを受け取る側の型を指定して、ProvidePropertyAttribute クラスの新しいインスタンスを初期化します。 |
Provide |
プロパティの名前とその ProvidePropertyAttribute を指定して、Type クラスの新しいインスタンスを初期化します。 |
Property |
このクラスが提供するプロパティの名前を取得します。 |
Receiver |
このプロパティが拡張できるデータ型の名前を取得します。 |
Type |
この属性の一意の識別子を取得します。 |
Type |
派生クラスで実装されると、この Attribute の一意の識別子を取得します。 (継承元 Attribute) |
Equals(Object) |
指定したオブジェクトの値が現在の ProvidePropertyAttribute と等しいかどうかを示す値を返します。 |
Get |
このインスタンスのハッシュ コードを返します。 |
Get |
現在のインスタンスの Type を取得します。 (継承元 Object) |
Is |
派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。 (継承元 Attribute) |
Match(Object) |
派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (継承元 Attribute) |
Memberwise |
現在の Object の簡易コピーを作成します。 (継承元 Object) |
To |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
_Attribute. |
一連の名前を対応する一連のディスパッチ識別子に割り当てます。 (継承元 Attribute) |
_Attribute. |
オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。 (継承元 Attribute) |
_Attribute. |
オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 (継承元 Attribute) |
_Attribute. |
オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。 (継承元 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 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。