RecommendedAsConfigurableAttribute Klasa

Definicja

Przestroga

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

Przestroga

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

Określa, że właściwość może być używana jako ustawienie aplikacji.

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
Dziedziczenie
RecommendedAsConfigurableAttribute
Atrybuty

Przykłady

W poniższym przykładzie właściwość jest tak użyteczna jak ustawienie aplikacji.

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

W następnym przykładzie pokazano, jak sprawdzić wartość RecommendedAsConfigurableAttribute elementu dla MyPropertyelementu . Najpierw kod pobiera PropertyDescriptorCollection element ze wszystkimi właściwościami obiektu. Następnie indeksuje element , PropertyDescriptorCollection aby uzyskać MyPropertywartość . Następnie zwraca atrybuty tej właściwości i zapisuje je w zmiennej atrybutów.

W tym przykładzie przedstawiono dwa różne sposoby sprawdzania wartości elementu RecommendedAsConfigurableAttribute. W drugim fragmentze kodu przykład wywołuje metodę Equals . W ostatnim fragmentcie kodu w przykładzie użyto RecommendedAsConfigurable właściwości do sprawdzenia wartości.

// 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

Jeśli oznaczyliśmy klasę za pomocą polecenia , użyj następującego RecommendedAsConfigurableAttributekodu, aby sprawdzić wartość.

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

Uwagi

Właściwości oznaczone zestawem do true wyświetlenia po rozwinięciu RecommendedAsConfigurableAttribute wiersza ConfigurableProperties w oknie Właściwości. Właściwość, która nie ma zalecanego ustawienia lub jest oznaczona RecommendedAsConfigurableAttribute ustawioną na wartość false , nie jest wyświetlana i jest mało prawdopodobnym kandydatem do bycia ustawieniem aplikacji. Wartość domyślna to false.

Możesz powiązać właściwość, która nie ma ustawienia RecommendedAsConfigurableAttribute w programie Visual Studio, klikając przycisk wielokropka (...) w obszarze Ustawienia w oknie Właściwości i wybierając odpowiednią właściwość z listy.

Uwaga

Gdy oznaczysz właściwość ustawioną RecommendedAsConfigurableAttribute na true, wartość tego atrybutu jest ustawiona na stały element członkowski Yes. Dla właściwości oznaczonej wartością ustawioną RecommendedAsConfigurableAttribute na wartość false, wartość to No. W związku z tym, jeśli chcesz sprawdzić wartość tego atrybutu w kodzie, musisz określić atrybut jako RecommendedAsConfigurableAttribute.Yes lub RecommendedAsConfigurableAttribute.No.

Aby uzyskać więcej informacji, zobacz Atrybuty.

.

Konstruktory

RecommendedAsConfigurableAttribute(Boolean)
Przestarzałe.
Przestarzałe.

Inicjuje nowe wystąpienie klasy RecommendedAsConfigurableAttribute.

Pola

Default
Przestarzałe.
Przestarzałe.

Określa wartość domyślną elementu RecommendedAsConfigurableAttribute, czyli No. To static pole jest tylko do odczytu.

No
Przestarzałe.
Przestarzałe.

Określa, że właściwość nie może być używana jako ustawienie aplikacji. To static pole jest tylko do odczytu.

Yes
Przestarzałe.
Przestarzałe.

Określa, że właściwość może być używana jako ustawienie aplikacji. To static pole jest tylko do odczytu.

Właściwości

RecommendedAsConfigurable
Przestarzałe.
Przestarzałe.

Pobiera wartość wskazującą, czy właściwość ta atrybut jest powiązana, może być używana jako ustawienie aplikacji.

TypeId
Przestarzałe.
Przestarzałe.

Po zaimplementowaniu w klasie pochodnej pobiera unikatowy identyfikator dla tego elementu Attribute.

(Odziedziczone po Attribute)

Metody

Equals(Object)
Przestarzałe.
Przestarzałe.

Wskazuje, czy to wystąpienie oraz określony obiekt są równe.

GetHashCode()
Przestarzałe.
Przestarzałe.

Zwraca wartość skrótu dla tego wystąpienia.

GetType()
Przestarzałe.
Przestarzałe.

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
IsDefaultAttribute()
Przestarzałe.
Przestarzałe.

Wskazuje, czy wartość tego wystąpienia jest wartością domyślną klasy.

Match(Object)
Przestarzałe.
Przestarzałe.

W przypadku zastąpienia w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()
Przestarzałe.
Przestarzałe.

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()
Przestarzałe.
Przestarzałe.

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)
Przestarzałe.
Przestarzałe.

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)
Przestarzałe.
Przestarzałe.

Pobiera informacje o typie obiektu, którego można użyć do pobrania informacji o typie interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)
Przestarzałe.
Przestarzałe.

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)
Przestarzałe.
Przestarzałe.

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy

Zobacz też