diff --git a/src/Intersvyaz.Core/Intersvyaz.Core.csproj b/src/Intersvyaz.Core/Intersvyaz.Core.csproj index 1e6ba33..fa80de6 100644 --- a/src/Intersvyaz.Core/Intersvyaz.Core.csproj +++ b/src/Intersvyaz.Core/Intersvyaz.Core.csproj @@ -123,7 +123,9 @@ + + diff --git a/src/Intersvyaz.Core/Services/ISettingsService.cs b/src/Intersvyaz.Core/Services/ISettingsService.cs new file mode 100644 index 0000000..fb25a9a --- /dev/null +++ b/src/Intersvyaz.Core/Services/ISettingsService.cs @@ -0,0 +1,24 @@ +using System; + +namespace Intersvyaz.Core.Services +{ + public interface ISettingsService + { + /// + /// Событие об изменении текущего пользователя. + /// + event EventHandler CurrentUserChanged; + + /// + /// Получить текущего пользователя. + /// + /// Имя пользователя. + string GetCurrentUser(); + + /// + /// Установить нового текущего пользователя. + /// + /// Имя нового пользователя. + void SetCurrentUser(string value); + } +} diff --git a/src/Intersvyaz.Core/Services/SettingsService.cs b/src/Intersvyaz.Core/Services/SettingsService.cs new file mode 100644 index 0000000..446c4ce --- /dev/null +++ b/src/Intersvyaz.Core/Services/SettingsService.cs @@ -0,0 +1,24 @@ +using System; +using Windows.Storage; + +namespace Intersvyaz.Core.Services +{ + public class SettingsService : ISettingsService + { + /// + public event EventHandler CurrentUserChanged; + + /// + public string GetCurrentUser() + { + return (string)ApplicationData.Current.LocalSettings.Values["CurrentUser"] ?? null; + } + + /// + public void SetCurrentUser(string value) + { + ApplicationData.Current.LocalSettings.Values["CurrentUser"] = value; + CurrentUserChanged?.Invoke(this, value); + } + } +}