Getting configuration data in .Net applications

Managing settings in a .Net application may sound like a simple thing but converting the data types and making sure they are the correct type makes it a bit more difficult.  The biggest problem is that you can end up having disconnected code everywhere doing type conversions and then you have to manage the data from the aspect of caching.  To that end, it is a good idea to create a simple class to keep each of the settings already converted to the correct type in a cache.  One thing to consider is that the cached data will need to be globally accessible and thread safe.

I have created some sample code that demonstrates the principal discussed.  My example code is using the ConfigurationManager library, but if you are using json configuration files this can be easily adapted for that.

Click here to get to my sample code.

Click here for my Gist.