private static string XmlSerialize(NetworkDTO value) { var xmlserializer = new XmlSerializer(typeof(NetworkDTO)); var stringWriter = new StringWriter(); var writer = XmlWriter.Create(stringWriter); xmlserializer.Serialize(writer, value); var serializeXml = stringWriter.ToString(); writer.Close(); return serializeXml; }
private static object DeserializeFromDTO(NetworkDTO message) { using (var memoryStream = new MemoryStream(message.Data)) return (new BinaryFormatter()).Deserialize(memoryStream); }