行业特定的资源实现行业、资源

2023-09-07 09:26:57 作者:赵阿冰。

我们有一个是用在一个特定的行业和具有特定于行业串的程序。我们现在有它可以在其他行业中使用的情况下,我们希望没有重复我们的code基地,定制该行业的字符串。

We have a program that is used in one specific industry and has strings that are specific to that industry. We now have the situation where it can be used in another industry and we want to customise the strings for that industry without duplicating our code base.

问题空间看起来非常本土化。难道要为每个行业单独的资源组装?如果是这样,当我们会选择使用哪个程序集,我们能否做到这一点,在安装时还是会需要在编译的时候?我们如何保持的单独的资源组件同步,因此,同样的键信息出现在每一个?

The problem space appears very similar to localisation. Are we going to have a separate resource assembly for each industry? If so when would we choose which assembly to use, could we do this at install time or would it need to be at compile time?. How do we keep the separate resource assemblies synchronised, so that the same keys to messages appear in each one?

什么是做到这一点的最好方法是什么?

What is the best way to do this?

推荐答案

让我重新句话吧:你有一个工业应用程序,它可以在各种行业中使用和的唯一的东西都是不同的是资源(即字符串,布局,也许图像和声音)。另外code 保持不变的

Let me re-phrase it: you have an industrial application which could be used in various industries and the only things that are different are resources (that is strings, layout, maybe images and sounds). The other code stays the same.

在这种情况下,你的问题不只是类似于它实际上是相同的本地化。正因为如此,你可以使用附属程序集。照片 现在,它是由你,如果要单独包装,例如创建的应用程序或分发一个应用程序与两个问题的空间。 第一似乎更真实的场景给我 - 你需要决定哪个.resx文件包含在的编译的时间(即在项目preparation你会覆盖现有资源,解决问题的空间资源和然后进行编译,这应该给你的应用程序的不同口味,我还可以修改自己在这种情况下,名称)。 后者将需要您手动实例的ResourceManager 在运行时从合法的卫星组装读 - 它可以根据一些配置文件。这意味着更多的工作(你需要实际修改code)和你最终会分发您的应用程序的两个口味的同时,那就是你会不会有超过你的客户将如何使用的控制权。从业务角度来看,它可能是一个有点危险。

In such case your problem is not just similar it is actually identical to Localization. And as such you can use Satellite Assemblies. Now, it is up to you if you want to package such created applications separately or distribute one application with both problem spaces. The first seem more realistic scenario to me - you would need to decide on which .resx file to include at compile time (i.e. during project preparation you would overwrite existing resources with problem-space resources and then proceed with compilation, that should give you different flavors of your application; I would also modify their names in such case). The latter would require you to manually instantiate ResourceManager at runtime to read from valid satellite assembly - it could be based on some configuration file. It means more work (you would need to actually modify your code) and you will end up distributing both flavors of your application at once, that is you won't have control over how your customers will use it. From the business perspective it could be a little dangerous.

修改(注意自我:阅读整个问题仔细)

不知怎的,我成功地想念安装时间与编译时间。我相信,编译时间,因为我给的配置驱动的开关部分由于同样的原因,答案:你将打包的资源,你不会对客户如何使用它的任何控制权。一些聪明的家伙就看着办吧,这是肯定的。

Somehow I managed to miss install time vs. compile time. I believe compile time is the answer because of the same reason I gave in config-driven switch section: you would package the resources and you won't have any control on how customers use it. Some clever guy would figure it out, that is for sure.