private void LoadSettingsFromFile() { _logger.LogMessage("load settings from file"); using (var stream = GetType().Assembly.GetManifestResourceStream(GetType().Assembly .GetManifestResourceNames() .FirstOrDefault(x => x.Contains("Settings.json")))) { if (stream != null) { using (var reader = new StreamReader(stream)) { var serializedData = reader.ReadToEnd(); var values = serializedData.FromJson <Dictionary <string, string> >(); SettingsLoader.InitializeDataObjects(Data, values, _logger); } } } if (Data.CanChangeServiceUrl) { var data = _cacheService.Get <TaxiHailSetting>(SettingsCacheKey); if (data != null && data.TaxiHail.ApplicationName.HasValue()) { if (Data.ServiceUrl != data.ServiceUrl) { _logger.LogMessage("CanChangeServiceUrl: url different in cache, using cached value {0}", data.ServiceUrl); Data.ServiceUrl = data.ServiceUrl; } } } _settingsFileLoaded = true; }
private async Task RefreshSettingsFromServer(bool getSettingsShouldThrowExceptionIfError = false) { _logger.LogMessage("load settings from server"); var settingsFromServer = await TinyIoCContainer.Current.Resolve <ConfigurationClientService>().GetSettings(getSettingsShouldThrowExceptionIfError); _cryptographyService.SwitchEncryptionStringsDictionary(Data.GetType(), null, settingsFromServer, false); SettingsLoader.InitializeDataObjects(Data, settingsFromServer, _logger, new[] { "ServiceUrl", "CanChangeServiceUrl" }); SaveSettings(); }
public async Task <ClientPaymentSettings> GetPaymentSettings() { var paymentSettings = new ClientPaymentSettings(); try { var result = await Client.GetAsync <Dictionary <string, string> >("/encryptedsettings/payments", logger : Logger); _cryptographyService.SwitchEncryptionStringsDictionary(paymentSettings.GetType(), null, result, false); SettingsLoader.InitializeDataObjects(paymentSettings, result, Logger); } catch (Exception ex) { Logger.LogError(ex, string.Empty, -1, true); } return(paymentSettings); }
public void Load() { SettingsLoader.InitializeDataObjects(ServerData, GetSettings(), null); }
public Task Load() { SettingsLoader.InitializeDataObjects(ServerData, GetSettings(), _logger); return(Task.FromResult(true)); }
private void SetSettingsValue(IDictionary <string, string> values) { SettingsLoader.InitializeDataObjects(ServerData, values, null); }