NeutralResourcesLanguageAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple:=False)> _ Public NotInheritable Class NeutralResourcesLanguageAttribute Inherits Attribute
[ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple=false)] public sealed class NeutralResourcesLanguageAttribute : Attribute
[ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets::Assembly, AllowMultiple=false)] public ref class NeutralResourcesLanguageAttribute sealed : public Attribute

NeutralResourcesLanguageAttribute は、アセンブリのニュートラル カルチャのリソースを書き込む言語を ResourceManager に通知します。また、リソース フォールバック プロセス を使用して、ニュートラル リソースを取得するために使用するアセンブリ (メイン アセンブリまたはサテライト アセンブリ) をResourceManager に通知することもできます。ニュートラル リソース言語と同じカルチャのリソースを検索する場合、ResourceManager は現在のスレッドの現在のユーザー インターフェイス カルチャでサテライト アセンブリを検索するのではなく、自動的にメイン アセンブリにあるリソースを使用します。これにより、読み込んだ最初のリソースに対する検索のパフォーマンスが向上し、ワーキング セットを縮小できます。
![]() |
---|
この属性をメイン アセンブリに適用して、メイン アセンブリで動作するニュートラル言語の名前を渡します。必要に応じて、UltimateResourceFallbackLocation 列挙体のメンバを渡して、フォールバック リソースを取得する場所を示すこともできます。この属性を使用することをお勧めします。 |

NeutralResourcesLanguageAttribute クラスを使用する例を次に示します。
Imports System Imports System.Resources Imports System.Globalization Imports System.Threading <assembly: NeutralResourcesLanguageAttribute("de", UltimateResourceFallbackLocation.Satellite)> Public Class Demo Public Overloads Shared Sub Main(ByVal args() As String) ' If a specific culture is passed in through the command line, use that -- otherwise ' just use the current ui culture Dim strCulture As String = "" If args.Length = 1 Then strCulture = args(0) End If If strCulture <> "" Then Try Thread.CurrentThread.CurrentUICulture = New CultureInfo(strCulture) Catch e As ArgumentException Console.WriteLine(e.Message, "Bad command-line argument") End Try Else Console.WriteLine("Current culture is: {0}", CultureInfo.CurrentUICulture.ToString()) End If Dim rm As ResourceManager Try rm = New ResourceManager("MyStrings", GetType(Demo).Assembly) Dim attr As New NeutralResourcesLanguageAttribute("de", UltimateResourceFallbackLocation.Satellite) Console.WriteLine(("Neutral language = " + rm.GetString("Language") + ", Fallback location = " + attr.Location.ToString() + ", Fallback culture = " + attr.CultureName.ToString())) Console.WriteLine(rm.GetString("MSG")) Catch e As MissingSatelliteAssemblyException Console.WriteLine(e.Message, "Unable to locate satellite Assembly") End Try End Sub 'Main End Class 'Demo
using System; using System.Resources; using System.Globalization; using System.Threading; [assembly: NeutralResourcesLanguageAttribute("de" , UltimateResourceFallbackLocation.Satellite)] public class Demo { public static void Main(string[] args) { // If a specific culture is passed in through the command line, use that -- otherwise // just use the current ui culture String strCulture = ""; if (args.Length == 1) { strCulture = args[0]; } if (strCulture != "") { try { Thread.CurrentThread.CurrentUICulture = new CultureInfo(strCulture); } catch (ArgumentException e){ Console.WriteLine(e.Message, "Bad command-line argument"); } } else Console.WriteLine("Current culture is: {0}", CultureInfo.CurrentUICulture.ToString()); ResourceManager rm; try { rm = new ResourceManager("MyStrings", typeof(Demo).Assembly); NeutralResourcesLanguageAttribute attr = new NeutralResourcesLanguageAttribute("de", UltimateResourceFallbackLocation.Satellite); Console.WriteLine("Neutral language = " + rm.GetString("Language") + ", Fallback location = " + attr.Location.ToString() + ", Fallback culture = " + attr.CultureName.ToString()); Console.WriteLine(rm.GetString("MSG")); } catch (MissingSatelliteAssemblyException e){ Console.WriteLine(e.Message, "Unable to locate satellite Assembly"); } } }
using namespace System; using namespace System::Resources; using namespace System::Globalization; using namespace System::Threading; [assembly:NeutralResourcesLanguageAttribute("de",UltimateResourceFallbackLocation::Satellite)]; public ref class Demo { public: int FallbackDemo() { array<String^>^args = Environment::GetCommandLineArgs(); // If a specific culture is passed in through the command line, use that -- otherwise // just use the current ui culture String^ strCulture = L""; if ( args->Length == 1 ) { strCulture = args[ 0 ]; } if ( !strCulture->Equals( L"" ) ) { try { Thread::CurrentThread->CurrentUICulture = gcnew CultureInfo( strCulture ); } catch ( ArgumentException^ e ) { Console::WriteLine( e->Message, L"Bad command-line argument" ); } } else Console::WriteLine( L"Current culture is: {0}", CultureInfo::CurrentUICulture ); ResourceManager^ rm; try { rm = gcnew ResourceManager( L"MyStrings",Demo::typeid->Assembly ); NeutralResourcesLanguageAttribute^ attr = gcnew NeutralResourcesLanguageAttribute( L"de",UltimateResourceFallbackLocation::Satellite ); Console::WriteLine( L"Neutral language = {0}, Fallback location = {1}, Fallback culture = {2}", rm->GetString( L"Language" ), attr->Location, attr->CultureName ); Console::WriteLine( rm->GetString( L"MSG" ) ); } catch ( MissingSatelliteAssemblyException^ e ) { Console::WriteLine( e->Message, L"Unable to locate satellite Assembly" ); } return 1; } }; void main() { Demo^ d = gcnew Demo; d->FallbackDemo(); }
import System.*; import System.Resources.*; import System.Globalization.*; import System.Threading.*; /** @assembly NeutralResourcesLanguageAttribute("de", UltimateResourceFallbackLocation.Satellite) */ public class Demo { public static void main(String[] args) { // If a specific culture is passed in through the command line, use // that -- otherwise just use the current ui culture String strCulture = ""; if (args.get_Length() == 1) { strCulture = args[0]; } if (!(strCulture.Equals(""))) { try { System.Threading.Thread.get_CurrentThread(). set_CurrentUICulture(new CultureInfo(strCulture)); } catch (ArgumentException e) { Console.WriteLine(e.get_Message(), "Bad command-line argument"); } } else { Console.WriteLine("Current culture is: {0}", CultureInfo.get_CurrentUICulture().ToString()); } ResourceManager rm; try { rm = new ResourceManager("MyStrings", Demo.class.ToType().get_Assembly()); NeutralResourcesLanguageAttribute attr = new NeutralResourcesLanguageAttribute("de" , UltimateResourceFallbackLocation.Satellite); Console.WriteLine("Neutral language = " + rm.GetString("Language") + ", Fallback location = " + attr.get_Location().ToString() + ", Fallback culture = " + attr.get_CultureName().ToString()); Console.WriteLine(rm.GetString("MSG")); } catch (MissingSatelliteAssemblyException e) { Console.WriteLine(e.get_Message(), "Unable to locate satellite Assembly"); } } //main } //Demo

System.Attribute
System.Resources.NeutralResourcesLanguageAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NeutralResourcesLanguageAttribute コンストラクタ (String, UltimateResourceFallbackLocation)
アセンブリ: mscorlib (mscorlib.dll 内)

Dim cultureName As String Dim location As UltimateResourceFallbackLocation Dim instance As New NeutralResourcesLanguageAttribute(cultureName, location)
public NeutralResourcesLanguageAttribute ( string cultureName, UltimateResourceFallbackLocation location )
public: NeutralResourcesLanguageAttribute ( String^ cultureName, UltimateResourceFallbackLocation location )
public NeutralResourcesLanguageAttribute ( String cultureName, UltimateResourceFallbackLocation location )
public function NeutralResourcesLanguageAttribute ( cultureName : String, location : UltimateResourceFallbackLocation )


NeutralResourcesLanguageAttribute コンストラクタを UltimateResourceFallbackLocation 列挙体と共に使用して、ResourceManager クラスでニュートラル フォールバック リソースをメイン アプリケーション アセンブリ (既定) から取得するか、または CurrentUICulture プロパティおよび FallbackLocation プロパティによって指定されたサテライト アセンブリから取得するかを指定します。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NeutralResourcesLanguageAttribute コンストラクタ (String)
アセンブリ: mscorlib (mscorlib.dll 内)




Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NeutralResourcesLanguageAttribute コンストラクタ

名前 | 説明 |
---|---|
NeutralResourcesLanguageAttribute (String) | NeutralResourcesLanguageAttribute クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
NeutralResourcesLanguageAttribute (String, UltimateResourceFallbackLocation) | 指定した最終的なリソース フォールバック位置で、NeutralResourcesLanguageAttribute クラスの新しいインスタンスを初期化します。 |

関連項目
NeutralResourcesLanguageAttribute クラスNeutralResourcesLanguageAttribute メンバ
System.Resources 名前空間
NeutralResourcesLanguageAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() ![]() | Location | リソース フォールバック プロセス を使用して、ニュートラル リソースを取得するために使う ResourceManager クラスの位置を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

NeutralResourcesLanguageAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

NeutralResourcesLanguageAttribute メンバ
アセンブリのニュートラル カルチャの ResourceManager を通知します。このクラスは継承できません。
NeutralResourcesLanguageAttribute データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | NeutralResourcesLanguageAttribute | オーバーロードされます。 NeutralResourcesLanguageAttribute クラスの新しいインスタンスを初期化します。 |

名前 | 説明 | |
---|---|---|
![]() ![]() | Location | リソース フォールバック プロセス を使用して、ニュートラル リソースを取得するために使う ResourceManager クラスの位置を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

- NeutralResourcesLanguageAttributeのページへのリンク