1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 16:53:26 +00:00

move some xamarin specific services to app proj

This commit is contained in:
Kyle Spearrin
2019-04-09 17:10:56 -04:00
parent 963b27fd71
commit 9e3ee50020
5 changed files with 6 additions and 5 deletions

View File

@@ -0,0 +1,53 @@
using Bit.Core;
using Bit.Core.Abstractions;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Bit.App.Services
{
public class MobileStorageService : IStorageService
{
private readonly IStorageService _preferencesStorageService;
private readonly IStorageService _liteDbStorageService;
private readonly HashSet<string> _preferenceStorageKeys = new HashSet<string>
{
Constants.LockOptionKey
};
public MobileStorageService(
IStorageService preferenceStorageService,
IStorageService liteDbStorageService)
{
_preferencesStorageService = preferenceStorageService;
_liteDbStorageService = liteDbStorageService;
}
public Task<T> GetAsync<T>(string key)
{
if(_preferenceStorageKeys.Contains(key))
{
return _preferencesStorageService.GetAsync<T>(key);
}
return _liteDbStorageService.GetAsync<T>(key);
}
public Task SaveAsync<T>(string key, T obj)
{
if(_preferenceStorageKeys.Contains(key))
{
return _preferencesStorageService.SaveAsync(key, obj);
}
return _liteDbStorageService.SaveAsync(key, obj);
}
public Task RemoveAsync(string key)
{
if(_preferenceStorageKeys.Contains(key))
{
return _preferencesStorageService.RemoveAsync(key);
}
return _liteDbStorageService.RemoveAsync(key);
}
}
}