mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-23 18:38:04 +08:00
34 lines
902 B
C#
34 lines
902 B
C#
using System.Threading.Tasks;
|
|
using Xamarin.Essentials;
|
|
|
|
namespace System.Security
|
|
{
|
|
/// <summary>
|
|
/// https://docs.microsoft.com/zh-cn/xamarin/essentials/secure-storage
|
|
/// </summary>
|
|
internal sealed class ClientStorage : IStorage
|
|
{
|
|
bool IStorage.IsNativeSupportedBytes => false;
|
|
|
|
Task<string?> IStorage.GetAsync(string key)
|
|
{
|
|
return SecureStorage.GetAsync(key);
|
|
}
|
|
|
|
Task IStorage.SetAsync(string key, string? value)
|
|
{
|
|
if (string.IsNullOrEmpty(value))
|
|
{
|
|
SecureStorage.Remove(key);
|
|
return Task.CompletedTask;
|
|
}
|
|
return SecureStorage.SetAsync(key, value);
|
|
}
|
|
|
|
Task<bool> IStorage.RemoveAsync(string key)
|
|
{
|
|
var result = SecureStorage.Remove(key);
|
|
return Task.FromResult(result);
|
|
}
|
|
}
|
|
} |