DescriptionAttribute Sınıf

Tanım

Bir özellik veya olay için açıklama belirtir.

public ref class DescriptionAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public class DescriptionAttribute : Attribute
public class DescriptionAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type DescriptionAttribute = class
    inherit Attribute
type DescriptionAttribute = class
    inherit Attribute
Public Class DescriptionAttribute
Inherits Attribute
Devralma
DescriptionAttribute
Türetilmiş
Öznitelikler

Örnekler

Aşağıdaki örnekte özelliği oluşturulur MyImage . özelliği, bir ve CategoryAttributeolmak üzere DescriptionAttribute iki özniteliğine sahiptir.

public:
   property Image^ MyImage 
   {
      [Description("The image associated with the control"),Category("Appearance")]
      Image^ get()
      {
         // Insert code here.
         return image1;
      }

      void set( Image^ value )
      {
         // Insert code here.
      }
   }
[Description("The image associated with the control"),Category("Appearance")] 
 public Image MyImage {
    get {
       // Insert code here.
       return image1;
    }
    set {
       // Insert code here.
    }
 }
<Description("The image associated with the control"), _
    Category("Appearance")> _
Public Property MyImage() As Image
    Get
        ' Insert code here.
        Return image1
    End Get
    Set
        ' Insert code here.
    End Set 
End Property

Sonraki örnek açıklamasını MyImagealır. İlk olarak kod, nesnenin tüm özelliklerine sahip bir PropertyDescriptorCollection alır. Ardından almak için dizinini PropertyDescriptorCollection oluşturur MyImage. Ardından bu özelliğin özniteliklerini döndürür ve öznitelikler değişkenine kaydeder.

Daha sonra örnek, içinden öğesini alıp DescriptionAttribute AttributeCollectionkonsol ekranına yazarak açıklamayı yazdırır.

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyImage" ]->Attributes;

/* Prints the description by retrieving the DescriptionAttribute 
      * from the AttributeCollection. */
DescriptionAttribute^ myAttribute = dynamic_cast<DescriptionAttribute^>(attributes[ DescriptionAttribute::typeid ]);
Console::WriteLine( myAttribute->Description );
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyImage"].Attributes;
 
 /* Prints the description by retrieving the DescriptionAttribute 
  * from the AttributeCollection. */
 DescriptionAttribute myAttribute = 
    (DescriptionAttribute)attributes[typeof(DescriptionAttribute)];
 Console.WriteLine(myAttribute.Description);
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("MyImage").Attributes

' Prints the description by retrieving the DescriptionAttribute
' from the AttributeCollection. 
Dim myAttribute As DescriptionAttribute = _
    CType(attributes(GetType(DescriptionAttribute)), DescriptionAttribute)
Console.WriteLine(myAttribute.Description)

Açıklamalar

Görsel tasarımcı, bir Özellikler penceresi gibi bileşen üyesine başvururken belirtilen açıklamayı görüntüleyebilir. Bu özniteliğin değerine erişmek için çağrısı Description .

Daha fazla bilgi için bkz . Öznitelikler.

Oluşturucular

DescriptionAttribute()

Parametresiz olarak sınıfının yeni bir örneğini DescriptionAttribute başlatır.

DescriptionAttribute(String)

Bir açıklama ile sınıfının yeni bir örneğini DescriptionAttribute başlatır.

Alanlar

Default

için DescriptionAttributeboş dize ("") olan varsayılan değeri belirtir. Bu static alan salt okunur.

Özellikler

Description

Bu öznitelikte depolanan açıklamayı alır.

DescriptionValue

Açıklama olarak depolanan dizeyi alır veya ayarlar.

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)

Verilen nesnenin değerinin geçerli DescriptionAttributedeğerine eşit olup olmadığını döndürür.

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()

Bunun varsayılan DescriptionAttribute örnek olup olmadığını belirten bir değer döndürür.

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.