public SerialParameters LoadParameters() { var param = new SerialParameters(); try { using (var reader = new StreamReader("Parameters.xml")) { var xs = new XmlSerializer(typeof(SerialParameters)); param = (SerialParameters)xs.Deserialize(reader); } } catch (Exception ex) { param = new SerialParameters() { BaudRate = 115200, DataBits = 8, Parity = Parity.None, Handshake = Handshake.None, StopBits = StopBits.One }; } return(param); }
public void SaveParameters(SerialParameters param) { using (var writer = new StreamWriter("Parameters.xml")) { var xs = new XmlSerializer(typeof(SerialParameters)); xs.Serialize(writer, param); } }