views:

173

answers:

1

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

+3  A: 

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 subclassing ConfigurationElement et al. allows a high degree of structural flexibility or to just parse the element yourself (override ConfigurationElement.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.

Richard
Thanks. I've also come across SettingsProvider today which seems to be a very simple way to add a custom settings provider to an app...any thought?
ng5000
Settings is not an area I really use, mostly is just some code generation wrapper around .config to make accessing values by name a little easier. But blocks some of the options of System.Configuration (e.g. getting a Configuration instance from an arbitrary file, making per-user config updatable).
Richard