我有很多本地资源文件
我想添加另一种语言,但我不想浏览所有文件夹并添加 SomeControl.ascx.de.resx 文件,例如,然后必须重新编译整个想法.
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.
我想使用附属程序集并将所有文件嵌入到 MyWebPage.de.dll 之类的文件中
I would like to use satellite assemblies and embed all the files into something like MyWebPage.de.dll
这在VS2003版本的全局资源中是可以的,但是我不确定在VS2008版本的本地资源中是否可以这样做?
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"/>
您的问题不是很清楚,您是在寻找 VS2008 的功能还是 ASP.NET 框架的功能.所以我会用代码解决方案.
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.
您使用的隐式绑定语法使用 ASP.NET 的默认 LocalResourceProvider,它采用资源所在的页面路径来计算要加载的资源.如果您的资源存储在其他地方,并且您仍想在前面的代码中使用隐式绑定系统税,您将需要使用您自己的 Provider.听起来很复杂,但其实很简单.
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.
要做到这一点,您需要首先将 ResourceProviderFactory 子类化
To do this you'll need to first subclass ResourceProviderFactory
并覆盖两者
IResourceProvider CreateGlobalResourceProvider(string classKey)
IResourceProvider CreateLocalResourceProvider(string virtualPath)
...然后实现您自己的 IResourceProvider,使用 ResourceManager 从附属程序集中获取资源
...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; }
}
然后您需要将配置添加到您的 web.config 文件,让 ASP.NET 知道使用您的 SatelliteResourceProviderFactory 并将您的资源移动到您的外部程序集,但这应该是您的好去处.
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/库/aa905797.aspx#exaspnet20rpm_topic4
这篇关于我可以在附属程序集中合并本地资源吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!