예제 #1
0
        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);
            }
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
 public void SaveData(ConfigurationObject dataToSave)
 {
     _dataProvider.SaveData(dataToSave);
 }
예제 #5
0
 public void RefreshData()
 {
     _configurationObject = _dataProvider.GetFreshData();
 }