public void SaveData(ConfigurationObject dataToSave) { string jsonThemeSettingsPath = GetThemeJasperJsonLocation(); string convertedDataToSave = JsonConvert.SerializeObject(dataToSave, Formatting.Indented); try { System.IO.File.WriteAllText(jsonThemeSettingsPath, convertedDataToSave); } catch (Exception ex) { throw new ConfigurationObjectProviderJsonException(ex); } }
/// <summary> /// /// </summary> /// <returns></returns> /// <exception cref="ConfigurationObjectProviderJsonException"></exception> public ConfigurationObject GetFreshData() { try { string jasperJsonUrl = GetThemeJasperJsonLocation(); string jsonSettings = System.IO.File.ReadAllText(jasperJsonUrl); ConfigurationObject configData = JsonConvert.DeserializeObject <ConfigurationObject>(jsonSettings); return(configData); } catch (Exception ex) { throw new ConfigurationObjectProviderJsonException(ex); } //string[] setting1 = configData.routing.homePage; //string key1 = configData.appSettings[0].key01; }
public WebsiteConfig(IWebsiteConfigProvider dataProvider) { this._dataProvider = dataProvider ?? throw new ConfigurationObjectException(); if (dataProvider == null) { throw new ConfigurationObjectException("Data provider parameter can't be null."); } try { ConfigurationObject settingsFromThemeJasperJson = _dataProvider.GetFreshData(); this._configurationObject = settingsFromThemeJasperJson; } catch { this._configurationObject = null; } }
public void SaveData(ConfigurationObject dataToSave) { _dataProvider.SaveData(dataToSave); }
public void RefreshData() { _configurationObject = _dataProvider.GetFreshData(); }