We created our own application settings and placed them in TheBeerHouse section of web.config. The ConfigSection.cs provides us with a configuration tier to get at the application settings. There is really nothing mysterious about it. Each configuration level within web.config has a corresponding class in ConfigSection.cs that defines what is to be found and any default values. The top-level item is TheBeerHouse section which is defined when we inherit from ConfigurationSection. Notice that there are two properties that are not defined as elements (defaultConnectionStringName and defaultCacheDuration). Those properties have default values assigned so that if they are not defined in web.config those values are used. As it happens, defaultConnectionStringName is defined and defaultCacheDuration is not. We could override the defaultCacheDuration in this way:
<TheBeerHouse defaultConnectionStringName="LocalSqlServer" defaultCacheDuration=250 >
Each of the elements is defined as required, meaning that they are expected within TheBeerHouse configuration and each class which defines the element is inherited from ConfigurationElement. An element can also have properties and, in fact, they all do. Remember that each of the other tiered providers, etc. will use these configuration elements.
I hope that I have shed a little light on the subject.
|