LocalizableAttribute クラスとは? わかりやすく解説

LocalizableAttribute クラス

プロパティローカライズする必要があるかどうか指定します。このクラス継承できません。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class
 LocalizableAttribute
    Inherits Attribute
Dim instance As LocalizableAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class LocalizableAttribute :
 Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class LocalizableAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class LocalizableAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class LocalizableAttribute extends
 Attribute
解説解説

コンポーネントコード生成され時点で、LocalizableAttributetrue設定してマークされメンバプロパティ値はリソース ファイル保存されています。これらのリソース ファイルは、コード変更せずローカライズできます

既定では、ローカライズできる属性のないメンバまたは LocalizableAttributefalse設定してマークされメンバは、そのデータ型許可されていればそれぞれのプロパティ値をコードに対して永続化ます。それ以外場合メイン コンポーネントLocalizable設定されていればすべてのプロパティリソース ファイルに対して永続化されます既定値false です。

メモメモ

LocalizableAttributetrue設定してプロパティマークすると、この属性の値は定数メンバ Yes に設定されます。LocalizableAttributefalse設定してマークされプロパティ場合、値は No になります。したがってコード内でこの属性の値を確認する場合は、属性LocalizableAttribute.Yes または LocalizableAttribute.No として指定する必要があります

詳細については、属性概要属性使用したメタデータ拡張 の各トピック参照してください

使用例使用例

プロパティローカライズする必要があるとしてマークする例を次に示します

<Localizable(True)> _
Public Property MyProperty() As
 Integer
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
        ' Insert code here.
    End Set 
End Property

[Localizable(true)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
public:
   property int MyProperty 
   {
      [Localizable(true)]
      int get()
      {
         // Insert code here.
         return 0;
      }

      void set( int value
 )
      {
         // Insert code here.
      }
   }
/** @attribute Localizable(true)
 */
/** @property
 */
public int get_MyProperty()
{
    // Insert code here.
    return 0;
}//get_MyProperty

/** @property 
 */
public void set_MyProperty(int
 value)
{
    // Insert code here.
}//set_MyProperty
public Localizable(true)
function get MyProperty() : int{
  // Insert code here.  Property goes on getter only when a property
 has
  // both a getter and setter.
  return 0
}

function set MyProperty(value: int){
  // Insert code here.
}

MyPropertyLocalizableAttribute の値を確認する方法次の例に示します最初にオブジェクトすべてのプロパティ保持する PropertyDescriptorCollection を取得します次にPropertyDescriptorCollection から MyProperty取得します。そして、このプロパティ属性返し、その属性属性変数保存します

最後にmyAttribute を AttributeCollection にある LocalizableAttribute の値に設定しプロパティローカライズする必要があるかどうか確認します

' 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
// 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.
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).
    get_Item("MyProperty").get_Attributes();
// Checks to see if the property needs to be localized.
LocalizableAttribute myAttribute = (LocalizableAttribute)(attributes.
    get_Item(LocalizableAttribute.class.ToType()));
if (myAttribute.get_IsLocalizable()) {
    // Insert code here.
}
// Gets the attributes for the property.
var attributes : AttributeCollection = TypeDescriptor.GetProperties(this)["MyProperty"].Attributes

// Checks to see if the property needs to be localized.
var myAttribute : LocalizableAttribute = LocalizableAttribute(attributes(LocalizableAttribute))
if(myAttribute.IsLocalizable){
     // Insert code here.
}
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.LocalizableAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
LocalizableAttribute メンバ
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「LocalizableAttribute クラス」の関連用語

LocalizableAttribute クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



LocalizableAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS