RecommendedAsConfigurableAttribute Classe

Definizione

Attenzione

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

Attenzione

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

Consente di specificare che la proprietà può essere utilizzata come un'impostazione dell'applicazione.

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
Ereditarietà
RecommendedAsConfigurableAttribute
Attributi

Esempio

Nell'esempio seguente viene contrassegnata una proprietà utilizzabile come impostazione dell'applicazione.

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

Nell'esempio successivo viene illustrato come controllare il valore dell'oggetto RecommendedAsConfigurableAttribute per MyProperty. Prima di tutto il codice ottiene un PropertyDescriptorCollection oggetto con tutte le proprietà per l'oggetto. Successivamente indicizza nell'oggetto PropertyDescriptorCollection per ottenere MyProperty. Restituisce quindi gli attributi per questa proprietà e li salva nella variabile attributi.

In questo esempio vengono illustrati due modi diversi per controllare il valore di RecommendedAsConfigurableAttribute. Nel secondo frammento di codice, nell'esempio viene chiamato il Equals metodo . Nell'ultimo frammento di codice, nell'esempio viene usata la RecommendedAsConfigurable proprietà per controllare il valore.

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

Se è stata contrassegnata una classe con RecommendedAsConfigurableAttribute, usare il codice seguente per controllare il valore.

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

Commenti

Proprietà contrassegnate con il RecommendedAsConfigurableAttribute set da true visualizzare quando si espande la riga ConfigureableProperties nella finestra Proprietà . Una proprietà che non ha alcuna impostazione consigliata o contrassegnata con RecommendedAsConfigurableAttribute impostata su false non viene visualizzata ed è un candidato improbabile per essere un'impostazione dell'applicazione. Il valore predefinito è false.

È possibile associare una proprietà che non ha un'impostazione RecommendedAsConfigurableAttribute in Visual Studio facendo clic sul pulsante con i puntini di sospensione (...) in Impostazioni nella finestra Proprietà e selezionando la proprietà appropriata dall'elenco.

Nota

Quando si contrassegna una proprietà con RecommendedAsConfigurableAttribute impostata su true, il valore di questo attributo è impostato sul membro Yescostante . Per una proprietà contrassegnata con RecommendedAsConfigurableAttribute il valore falseimpostato su , il valore è No. Pertanto, quando si vuole controllare il valore di questo attributo nel codice, è necessario specificare l'attributo come RecommendedAsConfigurableAttribute.Yes o RecommendedAsConfigurableAttribute.No.

Per altre informazioni, vedere Attributi.

.

Costruttori

RecommendedAsConfigurableAttribute(Boolean)
Obsoleti.
Obsoleti.

Inizializza una nuova istanza della classe RecommendedAsConfigurableAttribute.

Campi

Default
Obsoleti.
Obsoleti.

Consente di specificare il valore predefinito per l'attributo RecommendedAsConfigurableAttribute, che è No. Questo campo static è di sola lettura.

No
Obsoleti.
Obsoleti.

Consente di specificare che una proprietà non può essere utilizzata come impostazione dell'applicazione. Questo campo static è di sola lettura.

Yes
Obsoleti.
Obsoleti.

Consente di specificare che una proprietà può essere utilizzata come impostazione dell'applicazione. Questo campo static è di sola lettura.

Proprietà

RecommendedAsConfigurable
Obsoleti.
Obsoleti.

Ottiene un valore che indica se la proprietà alla quale è associato questo attributo può essere utilizzata come impostazione dell'applicazione.

TypeId
Obsoleti.
Obsoleti.

Quando è implementata in una classe derivata, ottiene un identificatore univoco della classe Attribute.

(Ereditato da Attribute)

Metodi

Equals(Object)
Obsoleti.
Obsoleti.

Indica se questa istanza e un oggetto specificato sono uguali.

GetHashCode()
Obsoleti.
Obsoleti.

Restituisce il codice hash per l'istanza.

GetType()
Obsoleti.
Obsoleti.

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()
Obsoleti.
Obsoleti.

Indica se il valore dell'istanza è quello predefinito per la classe.

Match(Object)
Obsoleti.
Obsoleti.

Quando è sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza equivale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()
Obsoleti.
Obsoleti.

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()
Obsoleti.
Obsoleti.

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

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

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)
Obsoleti.
Obsoleti.

Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da Attribute)
_Attribute.GetTypeInfoCount(UInt32)
Obsoleti.
Obsoleti.

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)
Obsoleti.
Obsoleti.

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da Attribute)

Si applica a

Vedi anche