public Observe <PortableUnit> SaveJsonAsync <T>(string file, T data) where T : class { return(Observe.DeferredStart(() => { lock (this.syncRoot) { using (var storage = IsolatedStorageFile.GetUserStoreForApplication()) { this.CreateFolderForFile(storage, file); using (IsolatedStorageFileStream fileStream = storage.CreateFile(file)) { Json <T> .Instance.SerializeToStream(data, fileStream); fileStream.Flush(); } } } }).SubscribeOn(Scheduler.ThreadPool.Schedule)); }
public Observe <T> LoadJsonAsync <T>(string filePath) where T : class { return(Observe.DeferredStart(() => { lock (this.syncRoot) { using (var storage = IsolatedStorageFile.GetUserStoreForApplication()) { if (!storage.FileExists(filePath)) { return default(T); } using ( var input = new IsolatedStorageFileStream( filePath, FileMode.Open, FileAccess.Read, FileShare.Read, storage)) { return Json <T> .Instance.DeserializeFromStream(input); } } } }).SubscribeOn(Scheduler.ThreadPool.Schedule)); }
public Observe <PortableUnit> SaveStringAsync(string file, string text) { return(Observe.DeferredStart(() => this.Save(file, text)).SubscribeOn(Scheduler.ThreadPool.Schedule)); }
public Observe <string> LoadStringAsync(string file) { return(Observe.DeferredStart(() => this.Load(file)).SubscribeOn(Scheduler.ThreadPool.Schedule)); }