From 3f86bb0cd7e33c29e7374c0caee402b9fd30386e Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Thu, 2 Mar 2023 19:06:38 -0300 Subject: [PATCH] PM-1271 Removed StorageMediatorOptions and go to a plain parameters based approach (#2397) --- .../Abstractions/IStorageMediatorService.cs | 6 +++--- src/Core/Services/StorageMediatorOptions.cs | 8 -------- src/Core/Services/StorageMediatorService.cs | 20 +++++++++---------- 3 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 src/Core/Services/StorageMediatorOptions.cs diff --git a/src/Core/Abstractions/IStorageMediatorService.cs b/src/Core/Abstractions/IStorageMediatorService.cs index 49575f22d..27f47c155 100644 --- a/src/Core/Abstractions/IStorageMediatorService.cs +++ b/src/Core/Abstractions/IStorageMediatorService.cs @@ -9,8 +9,8 @@ namespace Bit.Core.Abstractions void Save(string key, T obj); void Remove(string key); - Task GetAsync(string key, StorageMediatorOptions options = default); - Task SaveAsync(string key, T obj, StorageMediatorOptions options = default); - Task RemoveAsync(string key, StorageMediatorOptions options = default); + Task GetAsync(string key, bool useSecureStorage = false); + Task SaveAsync(string key, T obj, bool useSecureStorage = false, bool allowSaveNull = false); + Task RemoveAsync(string key, bool useSecureStorage = false); } } diff --git a/src/Core/Services/StorageMediatorOptions.cs b/src/Core/Services/StorageMediatorOptions.cs deleted file mode 100644 index 8b1523a4e..000000000 --- a/src/Core/Services/StorageMediatorOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Bit.Core.Services -{ - public struct StorageMediatorOptions - { - public bool UseSecureStorage { get; set; } - public bool AllowSaveNull { get; set; } - } -} diff --git a/src/Core/Services/StorageMediatorService.cs b/src/Core/Services/StorageMediatorService.cs index 9966d2970..d54924ecb 100644 --- a/src/Core/Services/StorageMediatorService.cs +++ b/src/Core/Services/StorageMediatorService.cs @@ -33,30 +33,30 @@ namespace Bit.Core.Services _synchronousStorageService.Remove(key); } - public Task GetAsync(string key, StorageMediatorOptions options = default) + public Task GetAsync(string key, bool useSecureStorage = false) { - return GetAsyncStorage(options).GetAsync(key); + return GetAsyncStorage(useSecureStorage).GetAsync(key); } - public async Task SaveAsync(string key, T obj, StorageMediatorOptions options = default) + public async Task SaveAsync(string key, T obj, bool useSecureStorage = false, bool allowSaveNull = false) { - if (obj is null && !options.AllowSaveNull) + if (obj is null && !allowSaveNull) { - await GetAsyncStorage(options).RemoveAsync(key); + await GetAsyncStorage(useSecureStorage).RemoveAsync(key); return; } - await GetAsyncStorage(options).SaveAsync(key, obj); + await GetAsyncStorage(useSecureStorage).SaveAsync(key, obj); } - public Task RemoveAsync(string key, StorageMediatorOptions options = default) + public Task RemoveAsync(string key, bool useSecureStorage = false) { - return GetAsyncStorage(options).RemoveAsync(key); + return GetAsyncStorage(useSecureStorage).RemoveAsync(key); } - IStorageService GetAsyncStorage(StorageMediatorOptions options) + IStorageService GetAsyncStorage(bool useSecureStorage) { - return options.UseSecureStorage ? _secureStorageService : _storageService; + return useSecureStorage ? _secureStorageService : _storageService; } } }