mirror of
https://github.com/bitwarden/android.git
synced 2024-11-04 17:14:49 +03:00
40 lines
964 B
C#
40 lines
964 B
C#
|
using System;
|
|||
|
using Bit.App.Abstractions;
|
|||
|
using Plugin.Settings.Abstractions;
|
|||
|
|
|||
|
namespace Bit.App.Services
|
|||
|
{
|
|||
|
public class AppIdService : IAppIdService
|
|||
|
{
|
|||
|
private const string AppIdKey = "appId";
|
|||
|
private readonly ISettings _settings;
|
|||
|
private string _appId;
|
|||
|
|
|||
|
public AppIdService(ISettings settings)
|
|||
|
{
|
|||
|
_settings = settings;
|
|||
|
}
|
|||
|
|
|||
|
public string AppId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if(!string.IsNullOrWhiteSpace(_appId))
|
|||
|
{
|
|||
|
return _appId;
|
|||
|
}
|
|||
|
|
|||
|
_appId = _settings.GetValueOrDefault<string>(AppIdKey);
|
|||
|
if(!string.IsNullOrWhiteSpace(_appId))
|
|||
|
{
|
|||
|
return _appId;
|
|||
|
}
|
|||
|
|
|||
|
_appId = Guid.NewGuid().ToString();
|
|||
|
_settings.AddOrUpdateValue(AppIdKey, _appId);
|
|||
|
return _appId;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|