Example #1
0
        public static SettingBase Load(SettingBase defaultSetttings, string filename)
        {
            defaultSetttings.m_filename = filename;
            if (!File.Exists(filename))
            {
                return(defaultSetttings);
            }
            SettingBase settings = defaultSetttings;

            try
            {
                XmlSerializer serializer = new XmlSerializer(defaultSetttings.GetType());
                using (TextReader reader = new StreamReader(filename))
                {
                    settings            = (SettingBase)serializer.Deserialize(reader);
                    settings.m_filename = filename;
                }
            }
            catch (Exception ex)
            {
                log.Error(string.Format("Loading settings from file '{1}' to {0} failed.", defaultSetttings.GetType().ToString(), filename));
            }
            if (File.Exists(filename + ".tmp"))
            {
                File.Delete(filename + ".tmp");
            }
            return(settings);
        }
Example #2
0
        public static SettingBase Load(SettingBase defaultSettings, LocationType locationType, string name)
        {
            string filename = Path.Combine(DefaultLocation(locationType), name);

            return(Load(defaultSettings, filename));
        }
Example #3
0
 public static SettingBase Load(SettingBase defaultSettings, LocationType locationType)
 {
     return(Load(defaultSettings, locationType, defaultSettings.DefaultName()));
 }
Example #4
0
        public static SettingBase LoadFromPath(SettingBase defaultSettings, string path)
        {
            string filename = Path.Combine(path, defaultSettings.DefaultName());

            return(Load(defaultSettings, filename));
        }