我可以在卫星组件结合本地资源? [英] Can I combine local resources in satellite assemblies?

查看:156
本文介绍了我可以在卫星组件结合本地资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多的地方国土资源文件


  • /Controls/App_LocalResources/SomeControl.ascx.resx,

  • /Pages/App_LocalResources/SomePage.aspx.resx等。

我要添加另一种语言,我不想去通过所有的文件夹,并添加SomeControl.ascx.de.resx文件,例如,然后重新编译整个想法。

我想用卫星组件和所有文件嵌入到类似MyWebPage.de.dll

这是VS2003版的全球资源可能的,但我不知道我能做到这一点在VS2008版本本地资源?

我访问资源的语法:

 < ASP:标签ID =lblSomething=服务器元:获取ResourceKey =labelFirstName/>


解决方案

您的问题不是您是否正在寻找VS2008或功能ASP.NET框架的一个特征实在太清楚了。所以我会去的code解决方案。

您正在使用的隐式绑定语法使用ASP.NET的默认LocalResourceProvider这需要在页面下的资源为工作而生活了加载哪些资源的路径。如果你的资源都存储在别处,你仍然想使用隐式绑定systax在code在前面,您需要使用自己的供应商。听起来复杂,但它是相当简单的。

要做到这一点,你需要先子ResourceProviderFactory

和同时覆盖

  IResourceProvider CreateGlobalResourceProvider(字符串的ClassKey)
IResourceProvider CreateLocalResourceProvider(字符串virtualPath)

...然后实现自己的IResourceProvider从使用一个ResourceManager您的附属程序得到你的资源

 公共接口IResourceProvider
{
     GetObject的对象(字符串的ResourceKey,CultureInfo的文化);
     IResourceReader ResourceReader {搞定; }
}

您则需要添加配置你的web.config文件,让ASP.NET知道使用你的SatelliteResourceProviderFactory和向外部assemby移动你的资源,但应该是你去好。

文档的大量可以在这里找到......构建一个数据库资源提供者部分下...

<一个href=\"http://msdn.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_topic4\">http://msdn.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_topic4

I have a lot of local resourse files

  • /Controls/App_LocalResources/SomeControl.ascx.resx,
  • /Pages/App_LocalResources/SomePage.aspx.resx, etc.

I want to add another language and I do not want to go through all folders and add SomeControl.ascx.de.resx files for example and then have to recompile the whole think.

I would like to use satellite assemblies and embed all the files into something like MyWebPage.de.dll

This was possible in VS2003 version for global resources, but I'm not sure can I do it in VS2008 version for local resources?

I am accessing the resource with the syntax:

<asp:label id="lblSomething" runat="server" meta:resourcekey="labelFirstName"/>

解决方案

Your question isn't really too clear on whether you are looking for a feature of VS2008 or a feature of the ASP.NET framework. So I'll go with the code solution.

The implicit binding syntax you're using uses ASP.NET's default LocalResourceProvider which takes in the path of page under which the resources live to work out which resources to load. If your resources are stored elsewhere and you still want to use the implicit binding systax in your code in front you'll need to use your own Provider. Sounds complicated but it's fairly straightforward.

To do this you'll need to first subclass ResourceProviderFactory

and override both

IResourceProvider CreateGlobalResourceProvider(string classKey)
IResourceProvider CreateLocalResourceProvider(string virtualPath)

...then implement your own IResourceProvider that gets your resources from your satellite assemblies using a ResourceManager

public interface IResourceProvider
{
     object GetObject(string resourceKey, CultureInfo culture);
     IResourceReader ResourceReader { get; }
}

You then need to add configuration to your web.config file to let ASP.NET know to use your SatelliteResourceProviderFactory and move your resources in to your external assemby, but that should be you good to go.

Plenty of documentation can be found here...under the "Building a Database Resource Provider" section...

http://msdn.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_topic4

这篇关于我可以在卫星组件结合本地资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆