[英]What is the best strategy for grouping resources in a .NET application
Where should resource files go and at what granularity (application/assembly/namespace/class/...)? 资源文件应该放在哪里以及粒度(application / assembly / namespace / class / ...)?
Using a layered architecture one can split an applications into separate dedicated assemblies. 使用分层架构,可以将应用程序拆分为单独的专用程序集。 An advantage is that it is easier to manage dependencies and ensure that code does not get entwined. 一个优点是更容易管理依赖项并确保代码不会缠绕在一起。
During application wide refactoring, pieces can be split out into separate assemblies or moved into their own assembly. 在应用程序范围内的重构期间,可以将碎片拆分成单独的组件或移动到它们自己的组件中。 This could happen because the functionality had matured enough to be moved into the core layer or has become large enough to warrant moving it into its own assembly. 这可能发生,因为功能已经成熟到足以移动到核心层或已变得足够大以保证将其移动到其自己的组件中。
During the refactoring process resource might have to be moved. 在重构过程中,可能必须移动资源。 It might be more or less difficult depending on the strategy used for grouping resources and the type of refactoring being done. 根据用于分组资源的策略和正在进行的重构类型,它可能或多或少地困难。 Resources (strings, images, files, etc...) could have been grouped in quite a few ways: - in a single resource file per assembly, - in a resource file per namespace within an assembly, - in a resource file for each class, - in a single assembly shared by all assemblies within the application, - etc. 资源(字符串,图像,文件等)可以通过多种方式进行分组: - 在每个程序集的单个资源文件中, - 在程序集中每个命名空间的资源文件中, - 在每个资源文件中class, - 在应用程序内所有程序集共享的单个程序集中, - 等。
Refactoring is just one operation which could be affected by the chosen grouping strategy for resources. 重构只是一项可能受所选资源分组策略影响的操作。 Other operations, like translation of the strings in the resource files will also be influenced. 其他操作,如资源文件中字符串的翻译也会受到影响。
What grouping strategy is considered best and why? 什么分组策略被认为是最好的,为什么?
Just making more of a comment than an answer here, but you should have a look at this: MSDN Internationalization page . 只是在这里做出更多的评论而不是答案,但你应该看一下: MSDN国际化页面 。
Whatever decisions you make regarding resources should keep in mind how your structure will work with internationalization, if you have to go international then you will have big problems if your structure constricts you. 无论你对资源做出什么决定都应该记住你的结构如何与国际化合作,如果你必须走向国际化,那么如果你的结构收缩你就会遇到很大问题。
我通常将资源绑定到程序集,但如果您不确定将来会带来什么,那么共享资源dll可能是一个很好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.