/// <summary> /// </summary> /// <returns> /// </returns> public IObservable <SettingsContract> GetSettingsAsync() { lock (this.syncRoot) { if (this.userSettings != null) { return(Observable.Return(this.userSettings)); } } return((from settings in this.storage.LoadJsonAsync <SettingsContract>(SettingsFilePath) select settings ?? new SettingsContract { CensorshipEnabled = true, PlayNextMix = true, PreferredList = PreferredLists.Liked, PlayOverWifiOnly = false }).Do( s => { lock (this.syncRoot) { this.userSettings = s; } })); }
public async Task EnableHardKillSwitch() { SettingsContract settingsContract = _settingsContractProvider.GetSettingsContract(); settingsContract.KillSwitchMode = KillSwitchMode.Hard; await UpdateServiceSettingsInternal(settingsContract); }
public void Apply(SettingsContract settings) { using (ServiceChannel <ISettingsContract> channel = _channelFactory.Create <ISettingsContract>(Endpoint)) { channel.Proxy.Apply(settings); } }
private void Load() { if (_settings != null) { return; } _settings = _storage.Get() ?? new SettingsContract(); }
public void Apply(SettingsContract settings) { Ensure.NotNull(settings, nameof(settings)); _settings = settings; Save(); SettingsChanged?.Invoke(this, settings); }
public Task Disconnect(SettingsContract settings, VpnErrorTypeContract vpnError) { _logger.Info("Disconnect requested"); _serviceSettings.Apply(settings); _vpnConnection.Disconnect(Map(vpnError)); return(Task.CompletedTask); }
/// <summary> /// </summary> /// <param name="userSettings"> /// </param> private void LoadSettings(SettingsContract userSettings) { this.isSettingsLoaded = false; this.CensorshipEnabled = userSettings.CensorshipEnabled; this.PlayOverWifiOnly = userSettings.PlayOverWifiOnly; this.PlayNextMix = userSettings.PlayNextMix; this.PreferredList = this.preferredListMap[userSettings.PreferredList ?? PreferredLists.Created]; this.isSettingsLoaded = true; }
/// <summary> /// </summary> /// <param name="settings"> /// </param> /// <returns> /// </returns> public IObservable <PortableUnit> SaveSettingsAsync(SettingsContract settings) { return(this.storage.SaveJsonAsync(SettingsFilePath, settings).Do( s => { lock (this.syncRoot) { this.userSettings = settings; } })); }
private async Task UpdateServiceSettingsInternal(SettingsContract settingsContract) { try { await Task.Run(() => _client.Apply(settingsContract)); } catch (Exception ex) when(ex is CommunicationException || ex is TimeoutException || ex is TaskCanceledException) { _logger.Error(ex.CombinedMessage()); } }
public void Save(SettingsContract settings) { var filename = _config.ServiceSettingsFilePath; HandleException(() => { using var stream = new StreamWriter(filename); using var writer = new JsonTextWriter(stream); _serializer.Serialize(writer, settings); }, "Saving"); }
public SettingsContract Load() { var filename = _config.ServiceSettingsFilePath; SettingsContract result = null; HandleException(() => { using var stream = new StreamReader(filename); using var reader = new JsonTextReader(stream); result = _serializer.Deserialize <SettingsContract>(reader); }, "Loading"); return(result); }
public void Apply(SettingsContract settings) { Ensure.NotNull(settings, nameof(settings)); _settings.Apply(settings); }
private IObservable <PlayingMixContract> LoadNowPlayingAsync() { return(from settings in ProfileService.Instance.GetSettingsAsync().Do(s => this.userSettings = s) from nowPlaying in PlayerService.LoadNowPlayingAsync().Do(v => this.NowPlaying = v) select nowPlaying); }
public void Set(SettingsContract value) { _origin.Set(value); }