Beispiel #1
0
        public void LoadUserSettingsFromFile()
        {
            var dir = Path.Combine(_appSettings.Dirs.Config, "usersettings.json");

            if (File.Exists(dir))
            {
                _userSettings = JsonConvert.DeserializeObject <UserSettings>(File.ReadAllText(dir));
                OnUserSettingsChanged?.Invoke(this, new GenericEventArgs <UserSettings>(_userSettings));
            }
        }
Beispiel #2
0
        public async Task <UserSettings> SaveUserSettingsAsync(UserSettings userSettings, long version)
        {
            if (userSettings.MediaServer.ServerBaseUrl == "/")
            {
                userSettings.MediaServer.ServerBaseUrl = "";
            }

            _userSettings         = userSettings;
            _userSettings.Version = version;

            var strJson = JsonConvert.SerializeObject(_userSettings, Formatting.Indented);
            var dir     = Path.Combine(_appSettings.Dirs.Config, "usersettings.json");
            await File.WriteAllTextAsync(dir, strJson);

            CreateRollbarLogger();

            OnUserSettingsChanged?.Invoke(this, new GenericEventArgs <UserSettings>(_userSettings));
            return(_userSettings);
        }