private object Deserialize(EncryptableNetDataContractSerializer serializer, string data) { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(data))) { using (var reader = new XmlTextReader(stream)) { return serializer.ReadObject(reader); } } }
private string Serialize(EncryptableNetDataContractSerializer serializer, object graph) { using (var stream = new MemoryStream()) { using (var writer = new XmlTextWriter(stream, Encoding.UTF8)) { serializer.WriteStartObject(writer, graph); serializer.WriteObjectContent(writer, graph); serializer.WriteEndObject(writer); writer.Flush(); return Encoding.UTF8.GetString(stream.ToArray()); } } }