using System; using System.IO; using System.Collections.Generic; using System.Text; using System.Xml.Serialization; namespace MapPoint.SimpleClient { [Serializable()] public class Settings { static string FilePath; static XmlSerializer SettingsSerializer; static Settings() { FilePath = typeof(Settings).Assembly.GetModules()[0].Name + ".settings"; SettingsSerializer = new XmlSerializer(typeof(Settings)); } string _mappointUserName = String.Empty; string _mappointPassword = String.Empty; string _skyhookUserName = String.Empty; string _skyhookRealm = String.Empty; string _dataSource; public string MappointUserName { get { return _mappointUserName; } set { _mappointUserName= value; } } public string MappointPassword { get { return _mappointPassword; } set { _mappointPassword = value; } } public string SkyhookUserName { get { return _skyhookUserName; } set { _skyhookUserName = value; } } public string SkyhookRealm { get { return _skyhookRealm; } set { _skyhookRealm = value; } } public string DataSource { get { return _dataSource; } set { _dataSource = value; } } public void Save() { using (StreamWriter sw = new StreamWriter(FilePath)) { SettingsSerializer.Serialize(sw,this); } } public bool TryLoad() { if (File.Exists(FilePath)) { try { Settings s = null; using (StreamReader sr = new StreamReader(FilePath)) { s = (Settings)SettingsSerializer.Deserialize(sr); } this._mappointUserName = s._mappointUserName; this._mappointPassword = s._mappointPassword; this._skyhookUserName = s._skyhookUserName; this._skyhookRealm = s._skyhookRealm; this._dataSource = s._dataSource; } catch { return false; } return true; } return false; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)