mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
json settings
This commit is contained in:
parent
992cf033f2
commit
41321e3c9e
2 changed files with 15 additions and 5 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue