/// <summary> /// Saves the list of settings profiles. /// </summary> /// <param name="settingsProfiles">The list of available settings profiles</param> public bool SaveSettingsProfiles(List <Settings> settingsProfiles) { try { var writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Settings>)); var file = new StreamWriter(DefaultSettingsProfilesLocation); writer.Serialize(file, settingsProfiles); file.Close(); return(true); } catch (Exception e) { LoggingControl.Log("Error while saving settings", e); return(false); } }
/// <summary> /// Returns a list of available settings profiles that can be used by the app. Returns null if none are found. /// </summary> public List <Settings> GetSettingsProfiles() { try { if (!File.Exists(DefaultSettingsProfilesLocation)) { return(null); } System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(List <Settings>)); StreamReader file = new StreamReader(DefaultSettingsProfilesLocation); var settingsProfiles = (List <Settings>)reader.Deserialize(file); file.Close(); return(settingsProfiles); } catch (Exception e) { LoggingControl.Log("Error while retrieving settings profiles", e); return(null); } }
/// <summary> /// Returns the settings to be used by the application, returning null if none are found. /// </summary> public Settings GetSettings() { try { if (!File.Exists(DefaultSettingsFileLocation)) { return(null); } System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(Settings)); StreamReader file = new StreamReader(DefaultSettingsFileLocation); Settings settings = (Settings)reader.Deserialize(file); file.Close(); return(settings); } catch (Exception e) { LoggingControl.Log("Error while retrieving settings", e); return(null); } }