ProvidePropertyAttribute クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ProvidePropertyAttribute クラスの意味・解説 

ProvidePropertyAttribute クラス

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

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple:=True)> _
Public NotInheritable Class
 ProvidePropertyAttribute
    Inherits Attribute
Dim instance As ProvidePropertyAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true)]
 
public sealed class ProvidePropertyAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple=true)]
 
public ref class ProvidePropertyAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true)
 */ 
public final class ProvidePropertyAttribute
 extends Attribute
AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true)
 
public final class ProvidePropertyAttribute
 extends Attribute
解説解説

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

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

詳細については、属性概要属性使用したメタデータ拡張 の各トピック参照してください

使用例使用例

MyClassProvidePropertyAttributeマークし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.Object
   System.Attribute
    System.ComponentModel.ProvidePropertyAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からProvidePropertyAttribute クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からProvidePropertyAttribute クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からProvidePropertyAttribute クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ProvidePropertyAttribute クラス」の関連用語

ProvidePropertyAttribute クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProvidePropertyAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS