LocalizableAttribute.IsLocalizable Propriété

Définition

Obtient une valeur indiquant si une propriété doit être localisée.

public:
 property bool IsLocalizable { bool get(); };
public bool IsLocalizable { get; }
member this.IsLocalizable : bool
Public ReadOnly Property IsLocalizable As Boolean

Valeur de propriété

true si une propriété doit être localisée ; sinon, false.

Exemples

L’exemple suivant montre comment vérifier la valeur de la LocalizableAttribute valeur pour MyProperty. Tout d’abord, le code obtient une PropertyDescriptorCollection valeur avec toutes les propriétés de l’objet. Ensuite, le code est extrait MyProperty du PropertyDescriptorCollection. Ensuite, elle retourne les attributs de cette propriété et les enregistre dans la variable d’attributs.

Enfin, le code définit myAttribute la valeur du LocalizableAttribute dans le AttributeCollection code et vérifie si la propriété doit être localisée.

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

// Checks to see if the property needs to be localized.
LocalizableAttribute^ myAttribute = dynamic_cast<LocalizableAttribute^>(attributes[ LocalizableAttribute::typeid ]);
if ( myAttribute->IsLocalizable )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes =
   TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;

// Checks to see if the property needs to be localized.
LocalizableAttribute myAttribute =
   (LocalizableAttribute)attributes[typeof(LocalizableAttribute)];
if (myAttribute.IsLocalizable)
{
    // Insert code here.
}
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
   TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
       
' Checks to see if the property needs to be localized.
Dim myAttribute As LocalizableAttribute = _
   CType(attributes(GetType(LocalizableAttribute)), LocalizableAttribute)
   
If myAttribute.IsLocalizable Then
     ' Insert code here.
End If

S’applique à

Voir aussi