开发者

Is a dynamic ConfigurationSection possible in a simple manner?

In .NET 1.0, IConfigurationSectionHandler offered a clean, single method interface to implementing a configuration handler.

In .NET 2, ConfigurationSection came along, a great lumbering beast of complexity and static type enforcement, waving a banner proclaiming "Unknown evils will happen if you use IConfigurationSectionHandler!".

Being the rebel that I am, trying to shoehorn a plugin architecture into a ancient, static framework like .NET 2, I want a dynamic configuratio开发者_高级运维n section. Nothing static, just a nice tree of XML nodes or nested key/value pairs. Something that plugins can access without defining fragile serialization code.

Like XML was originally intended for, before it became the harbinger of fragile catch-22 web.config horrors and painful boilerplate serialization trees.

Is there any way I can just get an XMLElement instance, or XMLReader, please?


Considering the age of this post, you may have already found this same answer on your own...

You can implement a ConfigurationSection that only needs to override the protected method DeserializeSection(). Your custom config section does not need to follow the attribute based property pattern that is the norm for .NET 2 configuration.

DeserializeSection accepts an XmlReader as its only parameter. You can use that XmlReader to parse out the XML from within your section and expose that data any way you choose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜