Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ public class ApplicationDataContainer
private readonly SemaphoreSlim mutex = new SemaphoreSlim(1, 1);

const string STORAGE_NAME = "AppStorage.data";
IFile storageFile = null;
string storageFileName = null;

public ApplicationDataContainer(string name = STORAGE_NAME)
{
storageFile = FileSystem.Current.LocalStorage.CreateFileAsync(name, CreationCollisionOption.OpenIfExists).Result;
storageFileName = name;
var storageFile = FileSystem.Current.LocalStorage.CreateFileAsync(storageFileName, CreationCollisionOption.OpenIfExists).Result;
var data = CodePushUtils.GetJObjectFromFileAsync(storageFile).Result;

if (data != null)
Expand All @@ -90,14 +91,16 @@ async Task SaveAsync()
{
await mutex.WaitAsync().ConfigureAwait(false);
var jobject = JObject.FromObject(Values);
var storageFile = await FileSystem.Current.LocalStorage.CreateFileAsync(storageFileName, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
await storageFile.WriteAllTextAsync(JsonConvert.SerializeObject(jobject)).ConfigureAwait(false);
mutex.Release();
}

public async Task DeleteAsync()
{
Values.Clear();
await storageFile.DeleteAsync();
var storageFile = await FileSystem.Current.LocalStorage.CreateFileAsync(storageFileName, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
await storageFile.DeleteAsync().ConfigureAwait(false);
}
}
}