I created a custom resource provider that returns rows from our database to use for anything.
The problem is that I did not find a way to "iterate over" the cache of these elements and reload them from the database. Ideally, I did this every x minutes or manually when we update the cache and want to reload it.
Technically, this is easy. I store everything in a hash table, so just delete it and reload when necessary. However, since ResourceProviderFactory handles the loading of each resource class, and I'm not sure how to list the classes it creates.
Code Review:
public class ResourceProvider : IResourceProvider
{
private Dictionary<string, Dictionary<string, object>> _resourceCache
= new Dictionary<string, Dictionary<string, object>>();
private string _virtualPath;
private string _className;
public ResourceProvider(string virtualPath, string className)
{
_virtualPath = virtualPath;
_className = className;
}
public object GetObject(string resourceKey, CultureInfo culture)
{
...
}
}
public class ResourceProviderFactory :System.Web.Compilation.ResourceProviderFactory
{
public override IResourceProvider CreateGlobalResourceProvider(string classKey)
{
return new Cannla.Business.Resource.ResourceProvider(string.Empty, classKey);
}
...
...
}
, , , CreateGlobalResourceProvider (, , nuke , ), , - ResourceProviderFactory.
- ResourceProviderFactory IEnumerable -, , ?