DesignOnlyAttributeとは? わかりやすく解説

DesignOnlyAttribute クラス

プロパティ設定できるのがデザイン時だけかどうか指定します

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

<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class
 DesignOnlyAttribute
    Inherits Attribute
Dim instance As DesignOnlyAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class DesignOnlyAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class DesignOnlyAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class DesignOnlyAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class DesignOnlyAttribute extends
 Attribute
解説解説
使用例使用例

GetLanguage プロパティ作成する例を次に示します。このプロパティは、DesignOnlyAttributeマークされます。

<DesignOnly(True)> _
Public Property GetLanguage() As
 CultureInfo
    Get
        ' Insert code here.
        Return myCultureInfo
    End Get
    Set
        ' Insert code here.
    End Set
End Property
[DesignOnly(true)]
 public CultureInfo GetLanguage {
    get {
       // Insert code here.
       return myCultureInfo;
    }
    set {
       // Insert code here.
    }
 }
public:
   [DesignOnly(true)]
   property CultureInfo^ GetLanguage 
   {
      CultureInfo^ get()
      {
         // Insert code here.
         return myCultureInfo;
      }
      void set( CultureInfo^ value )
      {
         // Insert code here.
      }
   }
/** @attribute DesignOnly(true)
 */
/** @property 
 */
public CultureInfo get_GetLanguage()
{
    // Insert code here.
    return myCultureInfo;
} //get_GetLanguage

/** @property 
 */
public void set_GetLanguage(CultureInfo value)
{
    // Insert code here.
} //set_GetLanguage

DesignOnlyAttribute の値を取得する例を次に示します最初にオブジェクトすべてのプロパティ保持する PropertyDescriptorCollection を取得します次にインデックス付けて PropertyDescriptorCollection から GetLanguage プロパティ検索します。そして、このプロパティ属性返し、その属性属性変数保存します

最後に、AttributeCollection から DesignOnlyAttribute取得し取得した情報コンソール画面書き込むことによって、プロパティ設定できるのがデザイン時だけかどうか出力します

' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("GetLanguage").Attributes

' Prints the description by retrieving the DescriptionAttribute
' from the AttributeCollection. 
Dim myAttribute As DesignOnlyAttribute = _
    CType(attributes(GetType(DesignOnlyAttribute)), DesignOnlyAttribute)
Console.WriteLine(("This property is design only :"
 & _
    myAttribute.IsDesignOnly.ToString()))
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["GetLanguage"].Attributes;
 
 /* Prints the description by retrieving the DescriptionAttribute 
  * from the AttributeCollection. */
 DesignOnlyAttribute myAttribute = 
    (DesignOnlyAttribute)attributes[typeof(DesignOnlyAttribute)];
 Console.WriteLine("This property is design only :" +
    myAttribute.IsDesignOnly.ToString());
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this
 )[ "GetLanguage" ]->Attributes;

/* Prints the description by retrieving the DescriptionAttribute 
       * from the AttributeCollection. */
DesignOnlyAttribute^ myAttribute = dynamic_cast<DesignOnlyAttribute^>(attributes[
 DesignOnlyAttribute::typeid ]);
Console::WriteLine( "This property is design only :{0}", myAttribute->IsDesignOnly
 );
// Gets the attributes for the property.
AttributeCollection attributes = TypeDescriptor.GetProperties(this).
    get_Item("GetLanguage").get_Attributes();

/* Prints the description by retrieving the DescriptionAttribute 
   from the AttributeCollection. 
 */
DesignOnlyAttribute myAttribute = (DesignOnlyAttribute)(attributes.
    get_Item(DesignOnlyAttribute.class.ToType()));

Console.WriteLine("This property is design only :" 
    + System.Convert.ToString(myAttribute.get_IsDesignOnly()));
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.DesignOnlyAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignOnlyAttribute コンストラクタ


DesignOnlyAttribute フィールド


DesignOnlyAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ IsDesignOnly プロパティ設定できるのがデザイン時だけかどうかを示す値を取得します
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。 ( Attribute から継承されます。)
参照参照

関連項目

DesignOnlyAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor

DesignOnlyAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます指定したオブジェクトの値が現在の DesignOnlyAttribute と等しかどうかを示す値を返します
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。  
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性既定値かどうか判断します
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DesignOnlyAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor

DesignOnlyAttribute メンバ

プロパティ設定できるのがデザイン時だけかどうか指定します

DesignOnlyAttribute データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DesignOnlyAttribute DesignOnlyAttribute クラス新しインスタンス初期化します。
パブリック フィールドパブリック フィールド
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ IsDesignOnly プロパティ設定できるのがデザイン時だけかどうかを示す値を取得します
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。(Attribute から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます指定したオブジェクトの値が現在の DesignOnlyAttribute等しかどうかを示す値を返します
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。  
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性既定値かどうか判断します
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DesignOnlyAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor


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

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

辞書ショートカット

すべての辞書の索引

「DesignOnlyAttribute」の関連用語

DesignOnlyAttributeのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS