RecommendedAsConfigurableAttribute Clase

Definición

Precaución

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

Precaución

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

Especifica que la propiedad se puede utilizar como configuración de la aplicación.

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
Herencia
RecommendedAsConfigurableAttribute
Atributos

Ejemplos

En el ejemplo siguiente se marca una propiedad como utilizable como una configuración de aplicación.

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

En el ejemplo siguiente se muestra cómo comprobar el valor de para RecommendedAsConfigurableAttributeMyProperty. En primer lugar, el código obtiene con PropertyDescriptorCollection todas las propiedades del objeto . A continuación, se indexa en para PropertyDescriptorCollection obtener MyProperty. A continuación, devuelve los atributos de esta propiedad y los guarda en la variable attributes.

En este ejemplo se presentan dos formas diferentes de comprobar el valor de RecommendedAsConfigurableAttribute. En el segundo fragmento de código, el ejemplo llama al Equals método . En el último fragmento de código, en el ejemplo se usa la RecommendedAsConfigurable propiedad para comprobar el valor.

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

Si marcó una clase con RecommendedAsConfigurableAttribute, use el código siguiente para comprobar el valor.

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

Comentarios

Las propiedades marcadas con el RecommendedAsConfigurableAttribute conjunto que se van a true mostrar al expandir la línea ConfigurableProperties en la ventana Propiedades . No se muestra una propiedad que no tiene ningún valor recomendado o que está marcado con establecido false en RecommendedAsConfigurableAttribute y es poco probable que sea un candidato para ser una configuración de aplicación. De manera predeterminada, es false.

Puede enlazar una propiedad que no tiene un RecommendedAsConfigurableAttribute objeto a una configuración en Visual Studio haciendo clic en el botón de puntos suspensivos (...) en Configuración en la ventana Propiedades y seleccionando la propiedad adecuada de la lista.

Nota

Cuando se marca una propiedad con RecommendedAsConfigurableAttribute establecida en true, el valor de este atributo se establece en el miembro Yesconstante . Para una propiedad marcada con establecido en RecommendedAsConfigurableAttribute valor false, el valor es No. Por lo tanto, cuando desee comprobar el valor de este atributo en el código, debe especificar el atributo como RecommendedAsConfigurableAttribute.Yes o RecommendedAsConfigurableAttribute.No.

Para obtener más información, consulte Attributes (Atributos).

.

Constructores

RecommendedAsConfigurableAttribute(Boolean)
Obsoletos.
Obsoletos.

Inicializa una nueva instancia de la clase RecommendedAsConfigurableAttribute.

Campos

Default
Obsoletos.
Obsoletos.

Especifica el valor predeterminado de RecommendedAsConfigurableAttribute, que es No. Este campo static es de solo lectura.

No
Obsoletos.
Obsoletos.

Especifica que no se puede utilizar una propiedad como configuración de la aplicación. Este campo static es de solo lectura.

Yes
Obsoletos.
Obsoletos.

Especifica que una propiedad puede utilizarse como configuración de la aplicación. Este campo static es de solo lectura.

Propiedades

RecommendedAsConfigurable
Obsoletos.
Obsoletos.

Obtiene un valor que indica si la propiedad a la que está enlazado este atributo se puede utilizar como configuración de la aplicación.

TypeId
Obsoletos.
Obsoletos.

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.

(Heredado de Attribute)

Métodos

Equals(Object)
Obsoletos.
Obsoletos.

Indica si esta instancia y un objeto especificado son iguales.

GetHashCode()
Obsoletos.
Obsoletos.

Devuelve el código hash de esta instancia.

GetType()
Obsoletos.
Obsoletos.

Obtiene el Type de la instancia actual.

(Heredado de Object)
IsDefaultAttribute()
Obsoletos.
Obsoletos.

Indica si el valor de esta instancia es el valor predeterminado de la clase.

Match(Object)
Obsoletos.
Obsoletos.

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.

(Heredado de Attribute)
MemberwiseClone()
Obsoletos.
Obsoletos.

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()
Obsoletos.
Obsoletos.

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Implementaciones de interfaz explícitas

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

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.

(Heredado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)
Obsoletos.
Obsoletos.

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.

(Heredado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)
Obsoletos.
Obsoletos.

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).

(Heredado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)
Obsoletos.
Obsoletos.

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.

(Heredado de Attribute)

Se aplica a

Consulte también