There’s a large WPF application with several modules, windows, self-written controls, etc.
We need to persist state for some of elements of user interface. For example:
- windows layout;
- controls layout;
- last accepted input;
- various grids’ state(columns’ visibility, width, order)
.Settings file seems too plain for this because of no hierarchy in it.
Why can’t I just serialize some SettingsModel, containing everything I need and then restore it on application startup?
The very important requirement for persistence mechanism is that it shoud be extensible: If I refactor settings structure, and will try to de-serialize the file created with some previous version of SettingsModel class, I will obviously fail.
So the quiestion is: are there any frameworks for persisting complex settings?
The .Settings file supports changing the structure over time. You don’t even need to use the Settings.cs file you can make your own settings providers and have them populate from the config file, each with their own customized Upgrade method to handle changes in the structure.