MergablePropertyAttribute Sınıf

Tanım

Bu özelliğin bir Özellikler penceresi diğer nesnelere ait özelliklerle birleştirilebileceğini belirtir.

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
Devralma
MergablePropertyAttribute
Öznitelikler

Örnekler

Aşağıdaki örnek, bir özelliği birleştirmek için uygun olarak işaretler.

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

Sonraki örnekte için değerinin nasıl denetlenecekleri gösterilmektedir MergablePropertyAttributeMyProperty. İlk olarak kod, nesnenin tüm özelliklerini içeren bir PropertyDescriptorCollection alır. Ardından almak için dizinini PropertyDescriptorCollection oluşturur MyProperty. Ardından bu özelliğin özniteliklerini döndürür ve öznitelikler değişkenine kaydeder.

Örnek, değerini MergablePropertyAttributedenetlemenin iki farklı yolunu sunar. İkinci kod parçasında örnek, yöntemini bir static değerle çağırırEquals. Son kod parçasında örnek, değerini denetlemek için özelliğini kullanır 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

ile MergablePropertyAttributebir sınıfı işaretlediyseniz, değerini denetlemek için aşağıdaki kodu kullanın.

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

Açıklamalar

ayarıyla MergablePropertyAttributetrue işaretlenen özellikler, bir Özellikler penceresi diğer nesnelere ait özelliklerle birleştirilebilir. olarak ayarlanmış false olarak işaretlenen özelliklerin MergablePropertyAttribute ayrı olarak görüntülenmesi gerekir. Varsayılan değer: true.

Not

olarak ayarlanmış truebir özelliği MergablePropertyAttribute işaretlediğinizde, bu özniteliğin değeri sabit üye Yesolarak ayarlanır. özelliği olarak ayarlanmış olarak MergablePropertyAttribute işaretlenmiş bir özellik için falsedeğeridir No. Bu nedenle, kodunuzda bu özniteliğin değerini denetlemek istediğinizde özniteliğini veya MergablePropertyAttribute.Noolarak MergablePropertyAttribute.Yes belirtmeniz gerekir.

Daha fazla bilgi için bkz . Öznitelikler.

Oluşturucular

MergablePropertyAttribute(Boolean)

MergablePropertyAttribute sınıfının yeni bir örneğini başlatır.

Alanlar

Default

Varsayılan değeri belirtir; Yesyani bir özellik, bir Özellikler penceresi diğer nesnelere ait özelliklerle birleştirilebilir. Bu static alan salt okunur.

No

Bir özelliğin bir Özellikler penceresi diğer nesnelere ait özelliklerle birleştirilemeyeceğini belirtir. Bu static alan salt okunur.

Yes

Bir özelliğin bir Özellikler penceresi diğer nesnelere ait özelliklerle birleştirilebileceğini belirtir. Bu static alan salt okunur.

Özellikler

AllowMerge

Bu özelliğin bir Özellikler penceresi diğer nesnelere ait özelliklerle birleştirilip birleştirilemeyeceğini belirten bir değer alır.

TypeId

Türetilmiş bir sınıfta uygulandığında, bu Attributeiçin benzersiz bir tanımlayıcı alır.

(Devralındığı yer: Attribute)

Yöntemler

Equals(Object)

Bu örnek ile belirtilen bir nesnenin eşit olup olmadığını gösterir.

GetHashCode()

Bu örneğe ilişkin karma kodu döndürür.

GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
IsDefaultAttribute()

Bu özniteliğin varsayılan olup olmadığını belirler.

IsDefaultAttribute()

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin değerinin türetilmiş sınıf için varsayılan değer olup olmadığını gösterir.

(Devralındığı yer: Attribute)
Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

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

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.