LocalizableAttribute.IsLocalizable 屬性

定義

取得值,表示是否應該將屬性當地語系化。

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

屬性值

如果屬性應該當地語系化則為 true,否則為 false

範例

下列範例示範如何檢查 LocalizableAttribute 的值。MyProperty 首先,程式代碼會取得 PropertyDescriptorCollection 具有物件之所有屬性的 。 然後,程式代碼會從PropertyDescriptorCollection取得MyProperty。 接下來,它會傳回此屬性的屬性,並將其儲存在屬性變數中。

最後,程式代碼會將 設定myAttribute為中的 AttributeCollectionLocalizableAttribute,並檢查屬性是否需要當地語系化。

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

適用於

另請參閱