Migrate aurora-sharp-desktop
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
namespace Aurora.Services.Settings
|
||||
{
|
||||
public interface ISettingsService
|
||||
{
|
||||
ISettings AppSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user's username. This is persisted.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The default port to use. This is persisted.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
int DefaultPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The current sessions clientId. This is assigned by the server. This is not persisted.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
string ClientName { get; set; }
|
||||
|
||||
string LibraryLocation { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Plugin.Settings;
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
namespace Aurora.Services.Settings
|
||||
{
|
||||
public class SettingsService : ISettingsService
|
||||
{
|
||||
private Lazy<ISettings> _appSettings;
|
||||
private string _usernameKey = "username";
|
||||
private string _defaultPortKey = "port";
|
||||
|
||||
private string _libraryLocationKey = "libraryLocation";
|
||||
|
||||
public SettingsService()
|
||||
{
|
||||
}
|
||||
|
||||
public ISettings AppSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_appSettings == null)
|
||||
{
|
||||
_appSettings = new Lazy<ISettings>(() => CrossSettings.Current, LazyThreadSafetyMode.PublicationOnly);
|
||||
}
|
||||
|
||||
return _appSettings.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_appSettings = new Lazy<ISettings>(() => value, LazyThreadSafetyMode.PublicationOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The user's username. This is persisted.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string Username
|
||||
{
|
||||
get { return AppSettings.GetValueOrDefault(_usernameKey, ""); }
|
||||
set
|
||||
{
|
||||
AppSettings.AddOrUpdateValue(_usernameKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default port to use. This is persisted.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public int DefaultPort
|
||||
{
|
||||
get { return AppSettings.GetValueOrDefault(_defaultPortKey, 4005); }
|
||||
set { AppSettings.AddOrUpdateValue(_defaultPortKey, value); }
|
||||
}
|
||||
|
||||
public string LibraryLocation
|
||||
{
|
||||
get { return AppSettings.GetValueOrDefault(_libraryLocationKey, "~/Music"); }
|
||||
set { AppSettings.AddOrUpdateValue(_libraryLocationKey, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current sessions clientId. This is assigned by the server. This is not persisted.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string ClientName
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user