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

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

MergablePropertyAttribute クラス

[プロパティ] ウィンドウ内で、プロパティをほかのオブジェクト属すプロパティ組み合わせることができること指定します

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

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

MergablePropertyAttributetrue設定してマークされているプロパティは、他のオブジェクト属すプロパティと [プロパティ] ウィンドウ内で組み合わせることができますMergablePropertyAttributefalse設定してマークされているプロパティは、個別表示する必要があります既定値true です。

メモメモ

MergablePropertyAttributetrue設定してプロパティマークすると、この属性の値は定数メンバ Yes に設定されます。MergablePropertyAttribute プロパティfalse設定してマークされプロパティ場合、値は No になります。したがってコード内でこの属性の値を確認する場合は、属性MergablePropertyAttribute.Yes または MergablePropertyAttribute.No として指定する必要があります

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

使用例使用例

プロパティ組み合わせできるとしてマークする例を次に示します

<MergableProperty(True)> _
Public Property MyProperty() As
 Integer
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
        ' Insert code here.
    End Set 
End Property
[MergableProperty(true)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
public:
   [MergableProperty(true)]
   property int MyProperty 
   {
      int get()
      {
         // Insert code here.
         return 0;
      }
      void set( int value
 )
      {
         // Insert code here.
      }
   }
/** @attribute MergableProperty(true)
 */

/** @property
 */
public int get_MyProperty()
{
    // Insert code here.
    return 0;
} //get_MyProperty

/** @property
 */
public void set_MyProperty(int
 value)
{
    // Insert code here.
} //set_MyProperty 

public MergableProperty(true)
function get MyProperty() : int{
  // Insert code here.
  return 0
}

function set MyProperty(value : int){
  // Insert code here.
}

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

この例では、MergablePropertyAttribute の値を確認する 2 種類方法示します2 番目のコード片では、static使用して Equals メソッド呼び出します。最後コード片では、AllowMerge プロパティ使用して値を確認します

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

' Checks to see if the value of the MergablePropertyAttribute is Yes.
If attributes(GetType(MergablePropertyAttribute)).Equals(MergablePropertyAttribute.Yes)
 Then
    ' Insert code here.
End If 

' This is another way to see if the property is bindable.
Dim myAttribute As MergablePropertyAttribute
 = _
    CType(attributes(GetType(MergablePropertyAttribute)), MergablePropertyAttribute)
If myAttribute.AllowMerge Then
    ' Insert code here.
End If 
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
 
 // Checks to see if the value of the MergablePropertyAttribute is Yes.
 if(attributes[typeof(MergablePropertyAttribute)].Equals(MergablePropertyAttribute.Yes))
 {
    // Insert code here.
 }
 
 // This is another way to see if the property is bindable.
 MergablePropertyAttribute myAttribute = 
    (MergablePropertyAttribute)attributes[typeof(MergablePropertyAttribute)];
 if(myAttribute.AllowMerge) {
    // Insert code here.
 }
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this
 )[ "MyProperty" ]->Attributes;

// Checks to see if the value of the MergablePropertyAttribute is Yes.
if ( attributes[ MergablePropertyAttribute::typeid ]->Equals(
 MergablePropertyAttribute::Yes ) )
{
   // Insert code here.
}

// This is another way to see if the property is bindable.
MergablePropertyAttribute^ myAttribute = dynamic_cast<MergablePropertyAttribute^>(attributes[
 MergablePropertyAttribute::typeid ]);
if ( myAttribute->AllowMerge )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this).get_Item(
    "MyProperty").get_Attributes();

// Checks to see if the value of the MergablePropertyAttribute is Yes.
if (attributes.get_Item(
        MergablePropertyAttribute.class.ToType()).Equals
        (MergablePropertyAttribute.Yes)) {

    // Insert code here.
}

// This is another way to see if the property is bindable.
MergablePropertyAttribute myAttribute = ((MergablePropertyAttribute)
    (attributes.get_Item(MergablePropertyAttribute.class.ToType())));
if (myAttribute.get_AllowMerge()) {
    // Insert code here.
}
// Gets the attributes for the property.
var attributes : AttributeCollection = TypeDescriptor.GetProperties(this)["MyProperty"].Attributes

// Checks to see if the value of the MergablePropertyAttribute is Yes.
if(attributes(MergablePropertyAttribute).Equals(MergablePropertyAttribute.Yes)){
  // Insert code here.
}

// This is another way to see if the property is bindable.
var myAttribute : MergablePropertyAttribute = MergablePropertyAttribute(attributes(MergablePropertyAttribute))
if(myAttribute.AllowMerge){
  // Insert code here.
}

MergablePropertyAttribute使用してクラスマークした場合は、次のコード使用して値を確認します

Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(MergablePropertyAttribute)).Equals(MergablePropertyAttribute.Yes)
 Then
    ' Insert code here.
End If 
AttributeCollection attributes = 
    TypeDescriptor.GetAttributes(MyProperty);
 if(attributes[typeof(MergablePropertyAttribute)].Equals(MergablePropertyAttribute.Yes))
 {
    // Insert code here.
 }
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ MergablePropertyAttribute::typeid ]->Equals(
 MergablePropertyAttribute::Yes ) )
{
   // Insert code here.
}
AttributeCollection attributes =
    TypeDescriptor.GetAttributes("MyProperty");
if (attributes.get_Item(
        MergablePropertyAttribute.class.ToType()).Equals(
        MergablePropertyAttribute.Yes)) {
    // Insert code here.
}
var attributes : AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
if(attributes(MergablePropertyAttribute).Equals(MergablePropertyAttribute.Yes)){
    // Insert code here.
}
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.MergablePropertyAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MergablePropertyAttribute メンバ
System.ComponentModel 名前空間
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection
Attribute



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

辞書ショートカット

すべての辞書の索引

「MergablePropertyAttribute クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS