Library - Saving Application Settings to Flash

[title]Saving Application Settings to Flash[/title]
http://code.tinyclr.com/project/413/saving-application-settings-to-flash/
[line]
[01/02/2012 - Modified]
I moved the “serialization” from GetSettings to the base class SaveToFlash, which will allow different methods of serialization in the future without changing all derived classes.

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, and 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.

Hello Jasdev

I think your class would take profit of EWR. Indeed, if I am right InternalFlashStorage is not available for EMX… Detecting the target allows you to enable appropriately EWR or InternalFlashStorage.

What do you think about this?

Thanks @ leforban

Yes I agree. I will be porting it to EMX (Cobra) soon. if you have any suggestions on how this should be done, please post them here.

May be the first thing is to recognize the target with the SystemModelType function from GHIElectronics.NETMF.System namespace.

[url]http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/93af3622-966a-df66-c9fb-f77d35eaefd2.htm[/url]