private async Task <JObject> SetAsync(string key, string value) { var storageFolder = await GetAsyncStorageFolder(true).ConfigureAwait(false); var file = await storageFolder.CreateFileAsync(AsyncStorageHelpers.GetFileName(key), CreationCollisionOption.ReplaceExisting).ConfigureAwait(false); await FileExtensions.WriteAllTextAsync(file, value).ConfigureAwait(false); return(default(JObject)); }
private async Task <JObject> RemoveAsync(string key) { var storageFolder = await GetAsyncStorageFolder(false).ConfigureAwait(false); if (storageFolder != null) { var fileName = AsyncStorageHelpers.GetFileName(key); var storageItem = await storageFolder.TryGetItemAsync(fileName).AsTask().ConfigureAwait(false); if (storageItem != null) { await storageItem.DeleteAsync().AsTask().ConfigureAwait(false); } } return(null); }
private async Task <string> GetAsync(string key) { var storageFolder = await GetAsyncStorageFolder(false).ConfigureAwait(false); if (storageFolder != null) { var fileName = AsyncStorageHelpers.GetFileName(key); var storageItem = await storageFolder.TryGetItemAsync(fileName).AsTask().ConfigureAwait(false); if (storageItem != null) { var file = await storageFolder.GetFileAsync(fileName).AsTask().ConfigureAwait(false); return(await FileIO.ReadTextAsync(file).AsTask().ConfigureAwait(false)); } } return(null); }
private async Task <JObject> SetAsync(string key, string value) { try { var storageFolder = await GetAsyncStorageFolder(true).ConfigureAwait(false); var file = await storageFolder.CreateFileAsync(AsyncStorageHelpers.GetFileName(key), CreationCollisionOption.OpenIfExists).ConfigureAwait(false); await FileExtensions.WriteAllTextAsync(file, value).ConfigureAwait(false); return(default(JObject)); } catch (Exception ex) { return(new JObject { { "message", ex.Message }, { "fileName", ex.ToString() } }); } }
private async Task <JObject> RemoveAsync(string key) { var storageFolder = await GetAsyncStorageFolder(false).ConfigureAwait(false); if (storageFolder == null) { return(null); } var fileName = AsyncStorageHelpers.GetFileName(key); var existsCheck = await storageFolder.CheckExistsAsync(fileName).ConfigureAwait(false); if (existsCheck == ExistenceCheckResult.FileExists) { var storageItem = await storageFolder.GetFileAsync(fileName).ConfigureAwait(false); await storageItem.DeleteAsync().ConfigureAwait(false); } return(null); }
private async Task <string> GetAsync(string key) { var storageFolder = await GetAsyncStorageFolder(false).ConfigureAwait(false); if (storageFolder == null) { return(null); } var fileName = AsyncStorageHelpers.GetFileName(key); var existsCheck = await storageFolder.CheckExistsAsync(fileName).ConfigureAwait(false); if (existsCheck == ExistenceCheckResult.FileExists) { var storageItem = await storageFolder.GetFileAsync(fileName).ConfigureAwait(false); return(await FileExtensions.ReadAllTextAsync(storageItem).ConfigureAwait(false)); } return(null); }