Exemple #1
0
        public async void SaveAsync(CacheFolder cache)
        {
            savePending = true;
            if (!saving)
            {
                saving = true;
                try
                {
                    savePending = false;
                    Log.WriteLine("Saving DataStore at time : " + DateTime.Now.ToString());
                    IsolatedStorage <DataStore> store = new IsolatedStorage <DataStore>(cache);
                    await store.SaveToFileAsync(DataFile, this);

                    if (savePending)
                    {
                        SaveAsync(cache);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteLine("Error saving DataStore: " + ex.Message);
                }
                finally
                {
                    saving = false;
                }
            }
        }
Exemple #2
0
        public static async Task <DataStore> LoadAsync(CacheFolder cache)
        {
            IsolatedStorage <DataStore> store = new IsolatedStorage <DataStore>(cache);
            DataStore data = await store.LoadFromFileAsync(DataFile);

            if (data == null)
            {
                data = new DataStore();
            }
            else
            {
                foreach (var info in data.Cameras.ToArray())
                {
                    if (info.StaticImageUrl != null)
                    {
                        data.Cameras.Remove(info);
                    }
                }
            }
            return(data);
        }