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
[<System.AttributeUsage(System.AttributeTargets.All)>]
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, a DescriptionAttribute ve CategoryAttributeolmak üzere 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.
        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 özelliklerini içeren 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 alıp DescriptionAttributeAttributeCollectionkonsol 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

Name Description
DescriptionAttribute()

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

DescriptionAttribute(String)

Sınıfın DescriptionAttribute yeni bir örneğini bir açıklamayla başlatır.

Alanlar

Name Description
Default

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

Özellikler

Name Description
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

Name Description
Equals(Object)

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

GetHashCode()

Bu örneğin karma kodunu döndürür.

GetType()

Geçerli örneğin Type 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 Objectbasit bir kopyasını oluşturur.

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

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

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

Name Description
_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 kullanıma sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.