Реализован сервис настроек приложения.
This commit is contained in:
parent
afabd343f5
commit
01f9c3aa2f
3 changed files with 50 additions and 0 deletions
|
|
@ -123,7 +123,9 @@
|
|||
<Compile Include="Models\SessionData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\ISessionService.cs" />
|
||||
<Compile Include="Services\ISettingsService.cs" />
|
||||
<Compile Include="Services\SessionService.cs" />
|
||||
<Compile Include="Services\SettingsService.cs" />
|
||||
<EmbeddedResource Include="Properties\Intersvyaz.Core.rd.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
24
src/Intersvyaz.Core/Services/ISettingsService.cs
Normal file
24
src/Intersvyaz.Core/Services/ISettingsService.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
|
||||
namespace Intersvyaz.Core.Services
|
||||
{
|
||||
public interface ISettingsService
|
||||
{
|
||||
/// <summary>
|
||||
/// Событие об изменении текущего пользователя.
|
||||
/// </summary>
|
||||
event EventHandler<string> CurrentUserChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Получить текущего пользователя.
|
||||
/// </summary>
|
||||
/// <returns>Имя пользователя.</returns>
|
||||
string GetCurrentUser();
|
||||
|
||||
/// <summary>
|
||||
/// Установить нового текущего пользователя.
|
||||
/// </summary>
|
||||
/// <param name="value">Имя нового пользователя.</param>
|
||||
void SetCurrentUser(string value);
|
||||
}
|
||||
}
|
||||
24
src/Intersvyaz.Core/Services/SettingsService.cs
Normal file
24
src/Intersvyaz.Core/Services/SettingsService.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace Intersvyaz.Core.Services
|
||||
{
|
||||
public class SettingsService : ISettingsService
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<string> CurrentUserChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetCurrentUser()
|
||||
{
|
||||
return (string)ApplicationData.Current.LocalSettings.Values["CurrentUser"] ?? null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetCurrentUser(string value)
|
||||
{
|
||||
ApplicationData.Current.LocalSettings.Values["CurrentUser"] = value;
|
||||
CurrentUserChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue