Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
        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()));
        }