ProvidePropertyAttribute クラス
アセンブリ: System (system.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple:=True)> _ Public NotInheritable Class ProvidePropertyAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true)] public sealed class ProvidePropertyAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple=true)] public ref class ProvidePropertyAttribute sealed : public 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.Attribute
System.ComponentModel.ProvidePropertyAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ProvidePropertyAttribute クラスのページへのリンク