Example #1
0
 public static string ToJsonString(this IEnumerable <EventSet> events)
 {
     using (var stream = new MemoryStream())
     {
         using (IPayloadWriter writer = new JsonPayloadWriter(stream))
         {
             writer.Write(string.Empty, events);
         }
         stream.Position = 0;
         using (StreamReader reader = new StreamReader(stream))
         {
             return(reader.ReadToEnd());
         }
     }
 }
Example #2
0
        public static void WriteToStream(this IEnumerable <EventSet> events, Stream stream, PayloadFormat format)
        {
            IPayloadWriter writer = null;

            if (format == PayloadFormat.Binary)
            {
                writer = new BinaryPayloadWriter(stream);
            }
            else
            {
                writer = new JsonPayloadWriter(stream);
            }

            using (writer)
            {
                writer.Write(string.Empty, events);
            }
        }