public bool Persist() { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (var fs = new IsolatedStorageFileStream(Common.ChronometerStore, FileMode.Create, isf)) { DataContractJSONSerializationHelper.Serialize(fs, this); return(true); } } return(false); }
public bool Persist() { try { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (var fs = new IsolatedStorageFileStream(Common.IntervalBlockStore, FileMode.Create, isf)) { DataContractJSONSerializationHelper.Serialize(fs, this); return(true); } } } catch (Exception) { return(false); } }
public static IntervalBlockStore Prepare() { IntervalBlockStore intervalBlockStore = null; try { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { //isf.DeleteFile(StoreName); // try get from storage using (var fs = new IsolatedStorageFileStream(Common.IntervalBlockStore, FileMode.OpenOrCreate, isf)) { intervalBlockStore = DataContractJSONSerializationHelper.Deserialize(fs, typeof(IntervalBlockStore)) as IntervalBlockStore; } } } catch (IsolatedStorageException) { } // if not existant create new instance with default values return(intervalBlockStore ?? (new IntervalBlockStore())); }