mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
json settings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Bit.Core.Abstractions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -8,6 +9,10 @@ namespace Bit.Core.Services
|
||||
public class PreferencesStorageService : IStorageService
|
||||
{
|
||||
private string _keyFormat = "bwPreferencesStorage:{0}";
|
||||
private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
|
||||
public Task<T> GetAsync<T>(string key)
|
||||
{
|
||||
@@ -51,7 +56,7 @@ namespace Bit.Core.Services
|
||||
else
|
||||
{
|
||||
var val = Xamarin.Essentials.Preferences.Get(formattedKey, default(string));
|
||||
return Task.FromResult(JsonConvert.DeserializeObject<T>(val));
|
||||
return Task.FromResult(JsonConvert.DeserializeObject<T>(val, _jsonSettings));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +95,7 @@ namespace Bit.Core.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Set(formattedKey, JsonConvert.SerializeObject(obj));
|
||||
Xamarin.Essentials.Preferences.Set(formattedKey, JsonConvert.SerializeObject(obj, _jsonSettings));
|
||||
}
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Bit.Core.Abstractions;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
@@ -8,6 +8,10 @@ namespace Bit.Core.Services
|
||||
public class SecureStorageService : IStorageService
|
||||
{
|
||||
private string _keyFormat = "bwSecureStorage:{0}";
|
||||
private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
|
||||
public async Task<T> GetAsync<T>(string key)
|
||||
{
|
||||
@@ -20,7 +24,7 @@ namespace Bit.Core.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(val);
|
||||
return JsonConvert.DeserializeObject<T>(val, _jsonSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +43,8 @@ namespace Bit.Core.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
await Xamarin.Essentials.SecureStorage.SetAsync(formattedKey, JsonConvert.SerializeObject(obj));
|
||||
await Xamarin.Essentials.SecureStorage.SetAsync(formattedKey,
|
||||
JsonConvert.SerializeObject(obj, _jsonSettings));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user