/// <summary> /// Десериализация параметров из XML файла "properties.cfg". /// </summary> /// <returns></returns> public static Parameters deserializeParams() { Parameters prop = new Parameters(); if (File.Exists("properties.cfg") == false) { XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(Parameters)); using (StreamWriter file = new System.IO.StreamWriter("properties.cfg")) { prop = new Parameters(); writer.Serialize(file, prop); } } else { try { XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(Parameters)); using (StreamReader file = new System.IO.StreamReader("properties.cfg")) { prop = (Parameters)reader.Deserialize(file); } } catch { File.Delete("properties.cfg"); deserializeParams(); } } return prop; }
public MainForm() { InitializeComponent(); prop = Parameters.deserializeParams(); tryConnection(); }
/// <summary> /// Конструктор окна настроек. /// </summary> /// <param name="param"> Параметры клиента.</param> public OptionForm(Parameters param) { InitializeComponent(); prop = param; }