This project is read-only.

Project Description

I was browsing a lot and i didnt find a solid solution, which would allow me to use an isolated storage fast and easy. What i want is to save/load classes as easy as possible and as fast as possible in async manner on WP7.5+.

Please, be aware, project is in active testing stage, and can be unstable. But i'm working on it :)

Current version contains 4 methods for storing composite data:

static async Task<T> ReadJsonAsync<T>(String filepath);
static async Task<bool> WriteJsonAsync<T>(String filepath, T content);

satic T ReadJson<T>(String fileName);
static void WriteJson<T>(String fileName, T data);

[!!!] Be careful to call async methods from events, as Task would probably not finished (especially if to fire Task from Application_Deactivated). In that case, use sync version.

Also, you can combine them: use WriteJson() when deactivating app and using ReadJsonAsync() when re-activating it again.

 And several methods to work with Isolated Settings (though, i'm trying to use it as rare as possible, as all strings are saved in one xml and storing lots of data can slow things down).

void SetSettingsProperty(string key, object content);
static object GetSettingsProperty(string key);
static T TryGetSettingsProperty<T>(string key, T @default);
static void RemoveSettingsProperty(string key); // The same as SetSettingsProperty(key, null);

As a bonus, project (application) contains a lightweight logger for performance testing of the release builds.

Whats inside
The magic is stored mostly here and particularly here.

Use IsolatedStorageSettings for storing shorter strings. - done
Also, i'm not sure about thread-safety. - done
Provide saving to binary (?)

Version 1.1.4 (22.05.2014)
* Quickfix: Json.Net is downgraded to 5.0.8, as 6.0.3 is not wp7 compatible (it would compile, but it will crash on the device).

Version 1.1.3 (17.05.2014)
* Quickfix: if fileName is empty, Writers and Readers would throw an exception

Version 1.1.2 (13.05.2014)
* Quickfix: added Mutex to AppendFile
* Quickfix: added JsonSerializer option TypeNameHandling for parsing inherited objects
* Logger is moved to the application

Version 1.1.1 (12.05.2014)
+ Added more trivial stuff, like DeleteDirectoryWithFiles(), FindFiles(), DeleteFile()

Version 1.0.1 (11.05.2014)
+ Added thread-safety via Mutexes. Another thread-safe resources are available inside: AwaitableCriticalSection and AsyncReaderWriterLock (see details here)
Published at NuGet

Revision 3 (28.04.2014)
+ Added IsolatedStorageSettings management (nice sample found here)

Revision 2: (26.04.2014)
+ 2 more methods for sync reading/writing json because calling async methods in eventhandlers can be dangerous in some cases (for example, inside Application_Deactivated())
+ Folder creation if necessary during Writing

Revision 1: (22.04.2014)
! Just initial revision
+ 4 async methods for reading/writing json/string.

3rd party tools
Newtonsoft.Json for serialization
Microsoft.Bcl.Async for asyncing on Wp7.5.


Special thanks to

Last edited May 22, 2014 at 5:54 PM by VeTaL, version 44