加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 多个资源文件与单个资源文件

发布时间:2020-12-15 21:58:41 所属栏目:百科 来源:网络整理
导读:这个问题与性能有关 我正在研究MVC4,我想支持多语言视图. 我正在为每种语言使用一个resourse文件,如下所示: Multi.resx For English as defaultMulti.ar.resx for Arabic Multi.fr.resx for Frensh 在指定文化之后,我在我的观点中这样做 @Multi.Name 但是,
这个问题与性能有关

我正在研究MVC4,我想支持多语言视图.

我正在为每种语言使用一个resourse文件,如下所示:

Multi.resx For English as default
Multi.ar.resx for Arabic 
Multi.fr.resx for Frensh

在指定文化之后,我在我的观点中这样做

@Multi.Name

但是,我创建了断点来检查@Multi的值,它实际上包含了我资源中的所有键.想象一下所有人:P

我的问题是:如果我为每个视图使用资源文件,它会表现得更好吗?或者,即使我为每个视图使用多个资源文件,在运行我的应用程序时是否会加载所有资源?

我真的不擅长英语,如果你不理解我的问题,请让我澄清一下.

解决方法

我知道这是旧线程,但我也在寻找答案.单个(和巨大的资源)文件会影响性能吗?

经过研究,我发现这个link,我想与你分享(如果你还在寻找).

嗯,简短的答案是否定的,它不会影响性能.但是,在大型团队中工作时可能会出现问题(每个程序员都需要修改相同的资源文件),并且合并更改会很麻烦.

以下是MSDN的指南:

Choosing Between Global and Local Resource Files

You can use any combination of global and local resource files in the Web application. Generally,you add resources to a global resource file when you want to share the resources between pages. Resources in global resource files are also strongly typed for when you want to access the files programmatically.

However,global resource files can become large,if you store all localized resources in them. Global resource files can also be more difficult to manage,if more than one developer is working on different pages but in a single resource file.

Local resource files make it easier to manage resources for a single ASP.NET Web page. But you cannot share resources between pages. Additionally,you might create lots of local resource files,if you have many pages that must be localized into many languages. If sites are large with many folders and languages,local resources can quickly expand the number of assemblies in the application domain.

When you make a change to a default resource file,either local or global,ASP.NET recompiles the resources and restarts the ASP.NET application. This can affect the overall performance of your site. If you add satellite resource files,it does not cause a recompilation of resources,but the ASP.NET application will restart.

我希望这可以帮助那些寻求相同答案的人.

干杯,山姆

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读