public void RemoveConfigFile(string name) { SettingsList.Remove(name); var path = MakeCurrentConfigFilePath(name); if (File.Exists(path)) { File.Delete(path); } }
public void RenameConfigFile(string oldName, string newName) { var oldPath = MakeCurrentConfigFilePath(oldName); var newPath = MakeCurrentConfigFilePath(newName); if (File.Exists(oldPath)) { File.Move(oldPath, newPath); } var index = SettingsList.IndexOf(oldName); SettingsList.Insert(index, newName); SettingsList.Remove(oldName); }
/// UpdateSettings (command) - Jacob Monger /// <summary> /// if valid updates setting /// </summary> /// <param name="message"> user input</param> public void UpdateSettings(object message) { if (SelectedSettingsIndex != -1) { if (double.TryParse(message.ToString(), out double newValue)) { String SettingsName = SettingsList[SelectedSettingsIndex].SettingsName; Properties.Settings.Default[SettingsName] = newValue; Properties.Settings.Default.Save(); SettingsList.Remove(SettingsList[SelectedSettingsIndex]); SettingsList.Insert(SelectedSettingsIndex, new SettingsListItemModel(SettingsName)); } } }
private void OnDeserializedMethod(StreamingContext context) { foreach (var tab in Tabs) { if (tab.BaseDir == null) { tab.BaseDir = GetSetting("BaseDir", tab.TabName); SettingsList.Remove(new Setting() { Scope = tab.TabName, Key = "BaseDir" }); } } }
/// <summary> /// Delete a setting /// </summary> /// <param name="setting"></param> public static void Delete(Setting setting) { if (_readOnly) { throw new Exception("Using reinitialize switch the SettingManager in read only mode"); } if (!IsInizialized) { throw new Exception(_ErrorMessage); } //Check arguments if (setting == null) { throw new ArgumentNullException(nameof(setting)); } var validationResults = Validate(setting); if (validationResults.Count > 0) { string Errors = String.Empty; foreach (var item in validationResults) { Errors = Errors + item.ErrorMessage + Environment.NewLine; } throw new ArgumentException(Errors); } //Inserisci logica inserimento/modifica var res = Get(setting.Name); if (res == null) { throw new Exception("Settig not found!"); } SettingsList.Remove(res); SaveFile(); }