Esempio n. 1
0
 public override string Serialize()
 {
     using (var memoryStream = new MemoryStream())
     {
         var jsonSerializer = new DataContractJsonSerializer(AuditPairs.GetType());
         jsonSerializer.WriteObject(memoryStream, AuditPairs);
         memoryStream.Flush();
         byte[] json = memoryStream.ToArray();
         memoryStream.Close();
         AuditPairs.Clear();
         return(Encoding.UTF8.GetString(json, 0, json.Length));
     }
 }
Esempio n. 2
0
        public override string Serialize()
        {
            var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
            var serializer      = new XmlSerializer(AuditPairs.GetType());
            var settings        = new XmlWriterSettings();

            settings.Indent             = true;
            settings.OmitXmlDeclaration = true;

            using (var stream = new StringWriter())
                using (var writer = XmlWriter.Create(stream, settings))
                {
                    serializer.Serialize(writer, AuditPairs, emptyNamepsaces);
                    AuditPairs.Clear();
                    return(stream.ToString());
                }
        }