From 2d197184f3a39cc3bc4a3acbb1ce202783f55186 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Tue, 5 Dec 2023 16:44:24 -0800 Subject: [PATCH] Fix platform storage for iOS --- Solitaire/Utils/PlatformProviders.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Solitaire/Utils/PlatformProviders.cs b/Solitaire/Utils/PlatformProviders.cs index 3fcdc2f..8f8c32f 100644 --- a/Solitaire/Utils/PlatformProviders.cs +++ b/Solitaire/Utils/PlatformProviders.cs @@ -27,12 +27,10 @@ private class DefaultSettingsStore : IRuntimeStorageProvider public async Task SaveObject(T obj, string key) { // Get a new isolated store for this user, domain, and assembly. - var isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | - IsolatedStorageScope.Domain | - IsolatedStorageScope.Assembly, null, null); + using var isoStore = IsolatedStorageFile.GetUserStoreForApplication(); // Create data stream. - await using var isoStream = new IsolatedStorageFileStream(Identifier + key, FileMode.Create, isoStore); + await using var isoStream = isoStore.OpenFile(Identifier + key, FileMode.CreateNew, FileAccess.Write); await JsonSerializer.SerializeAsync(isoStream, obj, typeof(T), JsonContext.Default); } @@ -41,10 +39,8 @@ public async Task SaveObject(T obj, string key) { try { - var isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | - IsolatedStorageScope.Domain | - IsolatedStorageScope.Assembly, null, null); - await using var isoStream = new IsolatedStorageFileStream(Identifier + key, FileMode.Open, isoStore); + using var isoStore = IsolatedStorageFile.GetUserStoreForApplication(); + await using var isoStream = isoStore.OpenFile(Identifier + key, FileMode.Open, FileAccess.Read); var storedObj = (T?)await JsonSerializer.DeserializeAsync(isoStream, typeof(T), JsonContext.Default); return storedObj ?? default; }