Luke Dalessandro
1/17/2006 11:08:00 PM
I have a class that gets configured by a custom web.config section sort
of like:
<custom>
<resources>
<add file="file.xml" />
</resources>
</custom>
public class CustomClass
{
private CustomSection m_section;
private XPathDocument m_costly; // essentially read-only
public CustomClass(CustomSection current)
{
m_section = current;
m_costly = GenerateCostlyXPathDocument();
}
private XPathDocument GenerateCostlyXPathDocument()
{
XPathDocument costly;
foreach (ResourceElement resource in m_config.Resources)
{
// Do some document merging, etc
costly = Merge(costly, resource.File);
}
return costly;
}
}
It's reasonably expensive to generate a new CustomClass... essentially,
it looks at the current configuration, and merges data files based on
what directory it's executing in. Fortunately, these documents change
very rarely.
I want to cache CustomClasses based on the resource file paths (no
problem), but also the web.config hierarchy for the currently executing
directory. In other words, a change to any of the actual resource files
will evict the CustomClass, but I also need a change to any of the
web.config files in the current hierarchy to evict the CustomClass.
Does anyone know how to make a CacheDependency based on web.config
files, other than actually searching the potentially virtual file paths
between the current execution directory and the application directory,
and accumulating web.config file paths.
I do have a reference to the current CustomSection, but I'm not sure
what to do with it to get the CustomClass to cache based on it...
Thanks in advance,
Luke