We have a configuration XML database. Rather than access this directly through the database API I’d like to extend .Net’s configuration classes to add a custom storage provider.
I’m not sure where to start. I’ve seen the Configuration Application Block but this seems to have been deprecated. I’m using .Net 3.5.
Which classes should I look at? Which interfaces do I need to implement? Has this been done elsewhere?
Thanks
You can load arbitrary files into the configuration system, but you will need to use ConfigurationManager.OpenMappedExeConfiguration passing a ExeConfigurationFileMap which includes you file.
But the file would need to be in .config format, using
<configuration>as the root element, and<configSections>to define custom sections. Once this is in place subclassingConfigurationElementet al. allows a high degree of structural flexibility or to just parse the element yourself (overrideConfigurationElement.DeserializeElement).Alternately, use some abstraction. Have a custom element in the normal .configuration, with a configuration section handler that loads a file specified in the main .config.