I just added a new entry to the Code section that demonstrates a base class that saves and restores application settings to and from Flash memory.
[url]http://code.tinyclr.com/project/413/saving-application-settings-to-flash/[/url]
FlashSettings is an abstract base class that provides methods for saving and loading application settings to and from flash memory. The class is defined in such a way the it allows multiple levels of derived classes to save and restore their settings in a safe and consistent manor. Each derived class may override these methods:
InitSettings - to set initial values for their settings when the constructor is called.
GetSettings - to retrieve the “serialized” values for their settings.
SetSettings - to set their settings from “serialized” values.
ValidateSettings - to validate their own settings before they are saved to flash memory.
The example project includes these two derived classes:
AppSettings : DeviceSettings
DeviceSettings : FlashSettings
The example attempts to load settings from flash, which will fail the first time it is run.
It then tries to save invalid Device settings, invalid App settings, and then valid Device and App settings to demonstrate how validation works.