开发者

Strategy for sharing resources between projects

I have a central library (DLL) called Core that is used by many projects (Some web apps, some win forms, some other class libraries).

Some resources are stored in the Core library.

When I need to use a resource file in the Core library, I need to know what the culture info is. Because it is sometimes used in a win form app, sometimes in a web app, I can't really use the culture from HttpContext or from the CurrentThread.

I imagine that this a common problem, so I 开发者_开发问答am wondering :

What's a good strategy to pass the culture information around between DAL dlls and UI projects?


You can always get the culture from the CurrentThread. It's supported both in WinForms and Web Applications. Even better: you'll probably won't need to bother about this at all, as the resource manager in .NET will handle this based on the current culture.


You can set the ui culture for a thread.

Then you are already fixed in case of WinForms.

In aspnet, you will need to set current ui culture for the thread. You can hook this procedure in a base controller's OnActionExecuted for this purpose (MVC) or use the PreInit event (webforms). This also can be done in an HttpModule.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜