Exemplo n.º 1
0
        public void Save()
        {
            var isoStorage = _isolatedStorageFileProvider.GetIsolatedStorage();

            using (var fs = new IsolatedStorageFileStream(_fileName, FileMode.OpenOrCreate, isoStorage))
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(fs, ForecastDataSet);
            }
        }
 private void ExecuteSave()
 {
     lock (LockObj)
     {
         try
         {
             var appScope = _isolatedStorageFileProvider.GetIsolatedStorage();
             using (var fs = new IsolatedStorageFileStream(OpenTimeEntriesXmlFile, FileMode.Create, appScope))
             {
                 var formatter = new XmlSerializer(typeof(ApplicationState));
                 formatter.Serialize(fs, _applicationState);
                 var        sb      = new StringBuilder();
                 TextWriter fwriter = new StringWriter(sb);
                 formatter.Serialize(fwriter, _applicationState);
             }
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
     }
 }
Exemplo n.º 3
0
        public Task <object> Save()
        {
            var sw = new Stopwatch();

            sw.Start();
            var taskCompletionSource = new TaskCompletionSource <object>();

            lock (LockObj)
            {
                using (var appScope = _isolatedStorageFileProvider.GetIsolatedStorage())
                {
                    using (var fs = new IsolatedStorageFileStream(appSettings.Default.TimeTrackerDataFile, FileMode.OpenOrCreate, appScope))
                    {
                        var formatter = new BinaryFormatter();
                        formatter.Serialize(fs, DataSet);
                        taskCompletionSource.SetResult(null);
                    }
                }
            }
            sw.Stop();
            Logger.Debug("Save(): " + sw.Elapsed);
            return(taskCompletionSource.Task);
        }