public bool TryDeserialize(string xml, out mdMsg message) { message = null; var result = true; try { message = Deserialize(xml); } catch { result = false; } return(result); }
public bool TrySerialize(mdMsg message, out string xml) { xml = null; var result = true; try { xml = Serialize(message); } catch { result = false; } return(result); }
public string Serialize(mdMsg message) { if (message == null) { return(null); } string xml; using (var memorySteam = new MemoryStream()) using (var writer = new XmlTextWriter(memorySteam, Encoding.UTF8)) { _serializer.Serialize(writer, message, _namespaces); memorySteam.Position = 0; using (var reader = new StreamReader(memorySteam)) { xml = reader.ReadToEnd(); } } return(xml); }