Here it is, guys. My configuration manager.
I really likes this syntax:
string ConStr = ConfigurationSettings.AppSettings["ConnectionString"];
But this is read-only application-wide settings, it doesn't help you if you
need to update the values, or want to use both application wide and user
For this, I designed my own configuration manager, usage is really simple:
string ConStr = Configuration.AppSettings["ConnectionString"];
So far, exactly like you would've done normally, the real power is in the following statements:
Configuration.AppSettings["ConnectionString"] = ConStr;
string Title = Configuration.UserSettings["Title"];
Configuration.UserSettings["HomePage"] = HomePageUri.ToString();
You can set the application settings, and you get user specific settings also
Considering that as a normal user you might not be able to make machine-wide changes, you also get the CanSetAppSettings property, that tells you whatever you are allowed to do so.
The settings are preserved as XML files in the following directories:
%CommonApplicationData%\<you application name\<major version>.<minor version>\<your application name>.config
%ApplicationData%\<you application name\<major version>.<minor version>\<your application name>.config
You can also get the file names programmatically using the UserFile and the AppFile properties.
You can iterate over the settings using the following syntax:
foreach(string key in Configuration.UserSettings)
There is a tiny optamization for when you set a lot of settings in one go, to avoid saving them one by one, the actual saving is done tenth of second after the last setting, or at application shut-down.
Curently the only limitation is that it can handle strings only (similar to the FCL's ConfigurationSettings). If there will be demand, I will add the ability to serialize objects directly from the Configuration class.
Get it here.