MergablePropertyAttribute クラス

定義

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

public ref class MergablePropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class MergablePropertyAttribute : Attribute
public sealed class MergablePropertyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type MergablePropertyAttribute = class
    inherit Attribute
type MergablePropertyAttribute = class
    inherit Attribute
Public NotInheritable Class MergablePropertyAttribute
Inherits Attribute
継承
MergablePropertyAttribute
属性

次の例では、マージに必要なプロパティをマークします。

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

次の例では、 の値をチェックする方法をMergablePropertyAttributeMyProperty示します。 最初に、コードは オブジェクトのすべてのプロパティを持つ を取得 PropertyDescriptorCollection します。 次に、 にインデックスを PropertyDescriptorCollection 作成して を取得 MyPropertyします。 次に、このプロパティの属性を返し、属性変数に保存します。

この例では、 の値を確認する 2 つの異なる方法を示します MergablePropertyAttribute。 2 番目のコード フラグメントでは、この例では 値を使用して Equals メソッドを static 呼び出します。 最後のコード フラグメントでは、 プロパティをAllowMerge使用して値をチェックします。

// 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)["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.
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

でクラスをマークした場合はMergablePropertyAttribute、次のコードを使用して値をチェックします。

AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ MergablePropertyAttribute::typeid ]->Equals( MergablePropertyAttribute::Yes ) )
{
   // Insert code here.
}
AttributeCollection attributes = 
    TypeDescriptor.GetAttributes(MyProperty);
 if(attributes[typeof(MergablePropertyAttribute)].Equals(MergablePropertyAttribute.Yes)) {
    // Insert code here.
 }
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(MergablePropertyAttribute)).Equals(MergablePropertyAttribute.Yes) Then
    ' Insert code here.
End If

注釈

に設定trueされたプロパティはMergablePropertyAttribute、プロパティ ウィンドウ内の他のオブジェクトに属するプロパティと組み合わせることができます。 にfalse設定されたプロパティはMergablePropertyAttribute、個別に表示する必要があります。 既定値は、true です。

Note

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

詳細については、「属性」を参照してください。

コンストラクター

MergablePropertyAttribute(Boolean)

MergablePropertyAttribute クラスの新しいインスタンスを初期化します。

フィールド

Default

既定値 Yes を指定します。この既定値は、[プロパティ] ウィンドウ内で別のオブジェクトに属するプロパティと組み合わせることができるプロパティです。 static フィールドは読み取り専用です。

No

[プロパティ] ウィンドウ内で、プロパティを別のオブジェクトに属するプロパティとは組み合わせることができないことを指定します。 static フィールドは読み取り専用です。

Yes

[プロパティ] ウィンドウ内で、プロパティを別のオブジェクトに属するプロパティとは組み合わせることができることを指定します。 static フィールドは読み取り専用です。

プロパティ

AllowMerge

[プロパティ] ウィンドウ内で、プロパティを別のオブジェクトに属するプロパティと組み合わせることができるかどうかを示す値を取得します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスと指定したオブジェクトが等しいかどうかを示します。

GetHashCode()

このインスタンスのハッシュ コードを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

この属性が既定値かどうかを判断します。

IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください