RecommendedAsConfigurableAttribute Sınıf

Tanım

Dikkat

Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.

Dikkat

RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.

özelliğinin bir uygulama ayarı olarak kullanılabileceğini belirtir.

public ref class RecommendedAsConfigurableAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
[System.Obsolete("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")]
public class RecommendedAsConfigurableAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public class RecommendedAsConfigurableAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
[System.Obsolete("RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.")]
public class RecommendedAsConfigurableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
[<System.Obsolete("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
[<System.Obsolete("RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.")>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute
Public Class RecommendedAsConfigurableAttribute
Inherits Attribute
Devralma
RecommendedAsConfigurableAttribute
Öznitelikler

Örnekler

Aşağıdaki örnek, bir özelliği uygulama ayarı olarak kullanılabilir olarak işaretler.

public:
   [RecommendedAsConfigurable(true)]
   property int MyProperty 
   {
      int get()
      {
         // Insert code here.
         return 0;
      }
      void set( int /*value*/ )
      {
         // Insert code here.
      }
   }
[RecommendedAsConfigurable(true)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
<RecommendedAsConfigurable(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 MyPropertydeğerinin nasıl denetlenecek olduğu gösterilmektedirRecommendedAsConfigurableAttribute. İlk olarak kod, nesnenin tüm özelliklerine sahip 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.

Bu örnekte değerini denetlemenin RecommendedAsConfigurableAttributeiki farklı yolu vardır. İkinci kod parçasında örnek yöntemini çağırır Equals . Son kod parçasında örnek, değerini denetlemek için özelliğini kullanır RecommendedAsConfigurable .

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

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

// This is another way to see if the property is recommended as configurable.
RecommendedAsConfigurableAttribute^ myAttribute = dynamic_cast<RecommendedAsConfigurableAttribute^>(attributes[ RecommendedAsConfigurableAttribute::typeid ]);
if ( myAttribute->RecommendedAsConfigurable )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes = 
   TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
 
// Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes.
if(attributes[typeof(RecommendedAsConfigurableAttribute)].Equals(RecommendedAsConfigurableAttribute.Yes)) {
   // Insert code here.
}
 
// This is another way to see if the property is recommended as configurable.
RecommendedAsConfigurableAttribute myAttribute = 
   (RecommendedAsConfigurableAttribute)attributes[typeof(RecommendedAsConfigurableAttribute)];
if(myAttribute.RecommendedAsConfigurable) {
   // 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 RecommendedAsConfigurableAttribute is Yes.
If attributes(GetType(RecommendedAsConfigurableAttribute)).Equals(RecommendedAsConfigurableAttribute.Yes) Then
    ' Insert code here.
End If 

' This is another way to see if the property is recommended as configurable.
Dim myAttribute As RecommendedAsConfigurableAttribute = _
    CType(attributes(GetType(RecommendedAsConfigurableAttribute)), RecommendedAsConfigurableAttribute)
If myAttribute.RecommendedAsConfigurable Then
    ' Insert code here.
End If

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

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

Açıklamalar

Özellikler penceresinde ConfigurableProperties satırını genişlettiğinizde görüntülenecek şekilde ayarlanmış true olarak RecommendedAsConfigurableAttribute işaretlenmiş özellikler. Önerilen ayarı olmayan veya olarak ayarlanmış false olarak RecommendedAsConfigurableAttribute işaretlenmiş bir özellik gösterilmez ve uygulama ayarı olma olasılığı düşük bir seçenektir. Varsayılan değer: false.

Visual Studio'da ayarı olmayan RecommendedAsConfigurableAttribute bir özelliği, Özellikler penceresindeki Ayarlar'ın altındaki üç nokta düğmesine (...) tıklayıp listeden uygun özelliği seçerek bağlayabilirsiniz.

Not

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

Daha fazla bilgi için bkz . Öznitelikler.

.

Oluşturucular

RecommendedAsConfigurableAttribute(Boolean)
Geçersiz.
Geçersiz.

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

Alanlar

Default
Geçersiz.
Geçersiz.

için RecommendedAsConfigurableAttributeNovarsayılan değerini belirtir. Bu static alan salt okunur.

No
Geçersiz.
Geçersiz.

Bir özelliğin uygulama ayarı olarak kullanılamadığını belirtir. Bu static alan salt okunur.

Yes
Geçersiz.
Geçersiz.

Bir özelliğin uygulama ayarı olarak kullanılabileceğini belirtir. Bu static alan salt okunur.

Özellikler

RecommendedAsConfigurable
Geçersiz.
Geçersiz.

Bu özniteliğin bağlı olduğu özelliğin bir uygulama ayarı olarak kullanılıp kullanılamayacağını belirten bir değer alır.

TypeId
Geçersiz.
Geçersiz.

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)
Geçersiz.
Geçersiz.

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

GetHashCode()
Geçersiz.
Geçersiz.

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

GetType()
Geçersiz.
Geçersiz.

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

(Devralındığı yer: Object)
IsDefaultAttribute()
Geçersiz.
Geçersiz.

Bu örneğin değerinin sınıfı için varsayılan değer olup olmadığını gösterir.

Match(Object)
Geçersiz.
Geçersiz.

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çersiz.
Geçersiz.

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

(Devralındığı yer: Object)
ToString()
Geçersiz.
Geçersiz.

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)
Geçersiz.
Geçersiz.

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)
Geçersiz.
Geçersiz.

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

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

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)
Geçersiz.
Geçersiz.

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

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.