I’ve been chomping away at my custom resource provider/manager and I have most of this working nicely with the ability to dynamically update resource content which was the original goal of this whole process.
But even as all of this is coming together I still feel a bit lost on the high level picture of the relationships between the ResourceProvider, ResourceManager and ResourceSets.
It looks to me that there’s one ResourceProvider per page, which in turn gets one ResourceSet at a time for each locale that is accessed. Locale information is pulled into ResourceSets one at a time it looks like as needed so as to minimize overhead until needed. The sets are cached automatically by the provider (or ResourceManager if one is used) so the resources load once and then stay cached.
All fine and good. ASP.NET allows overriding of the ResourceProvider via web.config and a custom implementation.
What I can’t figure out is how this actually happens and what is parceling out the ResourceManagers and Providers. For example, ASP.NET has a set of global resources which can be accessed with Resources.Resources. If you do this and look at the ResourceManager you’ll find that it’s the standard .NET resource manager not my custom resource manager.
It looks like there’s also no way to get a ‘global’ or ‘currently active’ reference to a ResourceProvider or ResourceManager. So if I’m in custom control how can I get a reference to the active ResourceProvider/Manager so I can do custom localization for example. Right now the control would have to know about a specific instance of the provider/manager.
I suppose I can use Page.GetLocalResourceObject(), PageGetGlobalResourceObject() for this? Is that the idea? These methods will go down to the active provider and do their thing properly. The page (or TemplateControl really) has its own ResourceProvider:
protected object GetLocalResourceObject(string resourceKey)
{
if (this._resourceProvider == null)
{
this._resourceProvider = ResourceExpressionBuilder.GetLocalResourceProvider(this);
}
return ResourceExpressionBuilder.GetResourceObject(this._resourceProvider, resourceKey, null);
}
But it’s not publicly accessible…
This makes it tough for example to ask for a ResourceWriter and write resources out to the resource store unless you hardcode to a specific provider…
Has anybody found some useful documentation that talks about the overall structure of the ResourceProvider model or more simply how to get access to the active ResourceProvider object?
Other Posts you might also like