Beispiel #1
0
        public PluginSetting <T> GetSetting <T>(string name, T defaultValue = default(T))
        {
            if (_settingEntities.ContainsKey(name))
            {
                return(new PluginSetting <T>(_pluginInfo, _pluginSettingRepository, _settingEntities[name]));
            }

            var settingEntity = new PluginSettingEntity {
                Name = name, PluginGuid = _pluginInfo.Guid, Value = JsonConvert.SerializeObject(defaultValue)
            };

            _pluginSettingRepository.Add(settingEntity);
            _pluginSettingRepository.Save();

            _settingEntities.Add(name, settingEntity);
            return(new PluginSetting <T>(_pluginInfo, _pluginSettingRepository, _settingEntities[name]));
        }
Beispiel #2
0
 /// <summary>
 ///     Saves the setting
 /// </summary>
 public void Save()
 {
     _pluginSettingEntity.Value = JsonConvert.SerializeObject(Value);
     _pluginSettingRepository.Save();
 }