NewsBot
1
When creating a configuration class.. I override the method:
InitializeDefault
I use to initialize our default values of the configuration section.. given that the section is registered at some point within the web.config inheritance, I don't even need to actually create the section to get defaults..
The odd thing I get from this however, is that any classes that use the configuration class cannot rely on it being 'found'..
I could request the current configuration section and it would return null.. but all I have to do to get an instance.. is to register them in the configSections part of the web.config.. so that the web.config is aware..
While I can somewhat see the logic behind this, what is confusing is that I don't have a default configuration.. unless the configuration is at least registered (put in the configSections area).. I don't need to actually create the section to get a default config.. but I DO need to at least register it..
This really made me wonder about how I should contain a default configuration?
My configuration class is open to be read by multiple end classes, and I'm wondering if I should instead have a class inbetween these, which acts as the delegate for creating default configurations instead.. (by checking for a configuration and otherwise returning a 'default' instance otherwise)..
Am I missing something here about defaults with configuration classes?
To me, given the way configuration sections actually end up being used, it seems that having a configuration class with a default configuration is somewhat pointless.. as to get a default configuration, the app itself must be configured anyway.. (isn't the point of a default to be there without doing anything at all?)..
More...
View All Our Microsoft Related Feeds
InitializeDefault
I use to initialize our default values of the configuration section.. given that the section is registered at some point within the web.config inheritance, I don't even need to actually create the section to get defaults..
The odd thing I get from this however, is that any classes that use the configuration class cannot rely on it being 'found'..
I could request the current configuration section and it would return null.. but all I have to do to get an instance.. is to register them in the configSections part of the web.config.. so that the web.config is aware..
While I can somewhat see the logic behind this, what is confusing is that I don't have a default configuration.. unless the configuration is at least registered (put in the configSections area).. I don't need to actually create the section to get a default config.. but I DO need to at least register it..
This really made me wonder about how I should contain a default configuration?
My configuration class is open to be read by multiple end classes, and I'm wondering if I should instead have a class inbetween these, which acts as the delegate for creating default configurations instead.. (by checking for a configuration and otherwise returning a 'default' instance otherwise)..
Am I missing something here about defaults with configuration classes?
To me, given the way configuration sections actually end up being used, it seems that having a configuration class with a default configuration is somewhat pointless.. as to get a default configuration, the app itself must be configured anyway.. (isn't the point of a default to be there without doing anything at all?)..
More...
View All Our Microsoft Related Feeds