LocalizableAttribute.IsLocalizable Proprietà

Definizione

Ottiene un valore che indica se una proprietà deve essere localizzata.

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

Valore della proprietà

true se una proprietà deve essere localizzata; in caso contrario, false.

Esempio

Nell'esempio seguente viene illustrato come controllare il valore di LocalizableAttribute per MyProperty. Innanzitutto, il codice ottiene un PropertyDescriptorCollection oggetto con tutte le proprietà per l'oggetto . Il codice ottiene MyProperty quindi da PropertyDescriptorCollection. Restituisce quindi gli attributi per questa proprietà e li salva nella variabile degli attributi.

Infine, il codice imposta myAttribute sul valore di LocalizableAttribute in AttributeCollection e controlla se la proprietà deve essere localizzata.

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

Si applica a

Vedi anche