The big value of application settings in .NET (called "Windows Forms Application Settings") is that they provide automatic persistence of settings, that can be configured per user.
Because of that, I only use them in the case of a rich client application, where I need the user to configure some settings that should persist when the user launches the application again. They are defined only by the application project, never by a library.
When the application is running, I will only use it twice:
- At application startup, I read the
Settings.Default object and put all the relevant values in my own configuration object, which is then the only one used by the application;
- When I want to save the settings (at application exit, when the user changes settings, etc.), I write into the
Settings.Default object the configuration values from my configuration object, and then call
Save() on it;
As for your dilemma (between "using an object" and "passing configuration values), they can be solved by a custom, mutable, configuration object:
- The rest of the application is passed only the configuration object (or a part of it), without knowing where it comes from (that is, no component should be coupled to the configuration by accessing it as a static property);
- Changes made by the user while the application is running goes to my configuration object, and the rest of the application is able to read changes to the configuration object as they happen;
One thing that you might want to do is, instead of copying the data from your own model to your own object, is to define a configuration interface, that would then be implemented by the Properties.Settings class. However that can get more complex if you have nested complex objects in your settings.
And if you have many configuration settings, then you should define multiple types for it - there is no reason for the code that queries a HTTP server to have access to the user's window color.
Also, please note that using the static property
Properties.Settings.Default directly falls under the case of the question:
Is a single config object a bad idea?