示例#1
0
        /// <summary>
        /// Saves the settings.
        /// </summary>
        /// <param name="currentSettings">The current settings.</param>
        public static void SaveSettings(SettingBase currentSettings)
        {
            var serializer = new XmlSerializer(typeof(SettingBase));
            var textreader = new StreamWriter(Path.Combine(Application.StartupPath, "Settings.xml"));

            serializer.Serialize(textreader, currentSettings);
            textreader.Close();
        }
示例#2
0
        /// <summary>
        /// Loads the settings.
        /// </summary>
        /// <param name="currentSettings">
        /// The current settings.
        /// </param>
        /// <returns>
        /// The load settings.
        /// </returns>
        public static SettingBase LoadSettings(SettingBase currentSettings)
        {
            var serializer = new XmlSerializer(typeof(List<SettingBase>));
            var textreader = new StreamReader(Path.Combine(Application.StartupPath, "Settings.xml"));

            var settings = (SettingBase)serializer.Deserialize(textreader);
            textreader.Close();

            return settings;
        }
示例#3
0
        /// <summary>
        /// Loads All the  settings.
        /// </summary>
        /// <returns>The Settings Class</returns>
        public static SettingBase LoadSettings()
        {
            SettingBase settings = new SettingBase();

            if (File.Exists(Path.Combine(Application.StartupPath, "Settings.xml")))
            {
                var serializer = new XmlSerializer(typeof(SettingBase));
                var textreader = new StreamReader(Path.Combine(Application.StartupPath, "Settings.xml"));

                settings = (SettingBase)serializer.Deserialize(textreader);
                textreader.Close();
            }

            SaveSettings(settings);

            return settings;
        }