IImplicitResourceProvider.GetImplicitResourceKeys 在 InitializeCulture 之前调用
我正在尝试实施基于 West Wind 数据库资源提供程序 的全球化解决方案。我正在实现 IImplicitResourceProvider 接口来使用隐式资源。但是,在页面上调用 InitializeCulture 之前,提供程序会在 GetImplicitResourceKeys 中获取隐式资源密钥。 GetImplicitResourceKeys 迭代适用于当前资源集的资源集,因此它需要了解文化是什么才能拥有正确的资源集。
我尝试通过页面指令、web.config 设置区域性,在线程上手动设置区域性,并覆盖 InitializeCulture,但这并不重要,因为在获取隐式资源之前永远不会设置区域性 - GetImplicitResourceKeys 始终是在InitializeCulture之前点击。这一切都发生在 PreInit 被触发之前。
我们使用的是 ASP.Net 4.0;我意识到西风解决方案是用 2.0 编写的。从那时起,页面工作流程是否发生了变化?不过,在文化确立之前获取资源并没有多大意义。
我需要做什么才能确保在调用 IImplicitResourceProvider.GetImplicitResourceKeys 之前设置区域性?
I'm trying to implement a globalization solution based off the West Wind database resource provider. I am implementing the IImplicitResourceProvider interface to use implicit resources. However, the implicit resource keys are fetched by the provider in GetImplicitResourceKeys before InitializeCulture is called on the page. GetImplicitResourceKeys iterates over the set of resources that apply to the current resource set, so it needs to know what the culture is to have the correct set of resources.
I've tried setting the culture through the page directive, the web.config, manually setting the culture on the thread, and overriding InitializeCulture but it doesn't matter because the culture is never set before the implicit resources are fetched - GetImplicitResourceKeys is always hit before InitializeCulture. This all happens before PreInit is even fired.
We are using ASP.Net 4.0; I realize the West Wind solution was written in 2.0. Has the page workflow changed since then? It doesn't make much sense to get the resources before the culture has been set though.
What do I need to do to make sure the culture is set before IImplicitResourceProvider.GetImplicitResourceKeys is called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是正确的行为,因为 GetImplicitResourceKeys 仅检索键,而不检索值。
仅当获取实际资源值时才需要区域性。
That would seem to be the correct behaviour, since GetImplicitResourceKeys only retrieves the keys, not the values.
You only need the culture when getting the actual resource values.