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); }
public static SettingBase Load(SettingBase defaultSettings, LocationType locationType, string name) { string filename = Path.Combine(DefaultLocation(locationType), name); return(Load(defaultSettings, filename)); }
public static SettingBase Load(SettingBase defaultSettings, LocationType locationType) { return(Load(defaultSettings, locationType, defaultSettings.DefaultName())); }
public static SettingBase LoadFromPath(SettingBase defaultSettings, string path) { string filename = Path.Combine(path, defaultSettings.DefaultName()); return(Load(defaultSettings, filename)); }