ResourceManager的名字问题

ResourceManager可以自动管理Assembly中的多语言资源,这使得多语言支持变得很容易。在生成一个ResourceManager实例的时候,有多个构造函数可以选择,罗列如下:

Protected method Supported by the .NET Compact Framework Supported by the XNA FrameworkResourceManager()()()Initializes a new instance of the ResourceManager class with default values.
Public method Supported by the .NET Compact Framework Supported by the XNA FrameworkResourceManager(Type)Creates a ResourceManager that looks up resources in satellite assemblies based on information from the specified Type.
Public method Supported by the .NET Compact Framework Supported by the XNA FrameworkResourceManager(String, Assembly)Initializes a new instance of the ResourceManager class that looks up resources contained in files derived from the specified root name using the given Assembly.
Public method Supported by the .NET Compact Framework Supported by the XNA FrameworkResourceManager(String, Assembly, Type)Initializes a new instance of the ResourceManager class that looks up resources contained in files derived from the specified root name using the given Assembly.

对于第三个和第四个,第一个参数为 String baseName。 baseName的解释是这样的:

The root name of the resources. For example, the root name for the resource file named "MyResource.en-US.resources" is "MyResource".

实际上,这个名字应当是NameSpaceOfAssembly+ResourceFileName.

如:

    AssemblyName: MyAssembly.Caculator

    ResourceFileNames: MyResource.Caculator.en.resx

                                     MyREsource.Caculator.it.resx

则baseName应该为:MyAssembly.Caculator.MyResource.Caculator。

如果resx文件位于某个文件夹下,则baseName中还要包含文件夹名字。

如:

   resx文件位于Resource/NLV

   baseName = MyAssembly.Caculator.Resource.NLV.MyResource.Caculator。

 

如果名字指定的不对,很可能会碰到调用GetString(String name)的时候,总是得不到想要的结果。因为ResourceManager实际上并没有加载指定的资源。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值