Monday 26 March 2012

Isolated Storage

Here’s a nice solution for dealing with WPF isolated storage.

It’s really simple to use, via a nice SaveSettings / ReadSetting interface.

You just need to create a class that holds all your settings as public properties and pass the object into the settings service.

isolated-storage-diagram

Saving to isolated storage

var settings = new ApplicationSettings
{
ShowTipsOnStartup = true,
ShowSplashScreen = false,
ItemsPerPage = 25
};

ISettingsProvider service = new SettingsProvider();
service.SaveSettings(settings);

Reading from isolated storage

ISettingsProvider service = new SettingsProvider();
var settings = service.GetSettings<ApplicationSettings>();


Source code:  http://stevenhollidge.com/blog-source-code/IsolatedSettings.zip

No comments:

Post a Comment