示例#1
0
        public void Delete(NoDbSetting setting)
        {
            var path = Path.Combine(_settingsFolder, setting.SettingsKey + ".json");

            File.Delete(path);
            ReadFromSettingsFolder();
        }
示例#2
0
        public void Save(NoDbSetting setting)
        {
            var json = ConversionHelper.Serialize(setting, isIndented: true);
            var path = Path.Combine(_settingsFolder, setting.SettingsKey + ".json");

            File.WriteAllText(path, json);
            ReadFromSettingsFolder();
        }
示例#3
0
        public void New(NoDbSetting setting)
        {
            if (string.IsNullOrWhiteSpace(setting.SettingsKey))
            {
                throw new Exception("Empty setting key!");
            }
            var path = Path.Combine(_settingsFolder, setting.SettingsKey + ".json");

            if (File.Exists(path))
            {
                throw new Exception("Setting key already exists!");
            }
            Save(setting);
        }