public virtual void Save(IFrontEndSettingsService settingsService) { // 5 load existing settings for this type var settings = new List <Setting>(); foreach (var propertyInfo in _properties) { object propertyValue = propertyInfo.GetValue(this, null); string value = (propertyValue == null) ? null : propertyValue.ToString(); // 7 create new setting var newSetting = new Setting() { Name = propertyInfo.Name, Type = _name, Value = value, }; settings.Add(newSetting); } if (settings != null && settings.Count > 0) { settingsService.SaveFrontEndSettings(settings); } }
private T CreateFrontEndSettings <T>(IFrontEndSettingsService settingsService, bool useCache) where T : FrontEndSettingsBase, new() { var settings = new T(); settings.Load(settingsService, useCache); return(settings); }
public void Save(IFrontEndSettingsService settingsService) { if (_generalFrontEndSettings != null) { _generalFrontEndSettings.Save(settingsService); } }
public void Save(string settingTypeName, IFrontEndSettingsService settingsService) { if (_generalFrontEndSettings != null && _generalFrontEndSettings.GetType().Name == settingTypeName) { _generalFrontEndSettings.Save(settingsService); return; } }
public virtual void Load(IFrontEndSettingsService settingsService, bool useCache) { // ARGUMENT CHECKING SKIPPED FOR BREVITY // 3 get settings for this type name var settings = settingsService.LoadFrontEndSettings(this._name, useCache).Result; if (settings != null && settings.Count > 0) { foreach (var propertyInfo in _properties) { // get the setting from the settings list var setting = settings.SingleOrDefault(s => s.Name == propertyInfo.Name); if (setting != null) { // 4 assign the setting values to the properties in the type inheriting this class propertyInfo.SetValue(this, Convert.ChangeType(setting.Value, propertyInfo.PropertyType)); } } } }
public FrontEndSystemController(IFrontEndSettingsService settingService, IActivityStore activityStore) { _frontSettingService = settingService; _activityStore = activityStore; }
public void Load(IFrontEndSettingsService settingsService, bool useCache = false) { _generalFrontEndSettings = CreateFrontEndSettings <GeneralFrontEndSettings>(settingsService, useCache); }