示例#1
0
 /// <summary>
 /// Serialize streamable into a binary stream
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="input"></param>
 /// <param name="binaryStream"></param>
 /// <param name="writePropertiesToStream"></param>
 public static void ToBinaryStream <TKey, TPayload>(this IStreamable <TKey, TPayload> input, Stream binaryStream, bool writePropertiesToStream = false)
 {
     if (writePropertiesToStream)
     {
         var propSer = StreamSerializer.Create <SerializedProperties>();
         propSer.Serialize(binaryStream, SerializedProperties.FromStreamProperties(input.Properties));
     }
     input.ToStreamMessageObservable()
     .Subscribe(new BinaryStreamObserver <TKey, TPayload>(input.Properties, binaryStream));
 }
示例#2
0
 internal static void ToTextStream <TKey, TPayload>(this IStreamable <TKey, TPayload> input, Stream textStream)
 {
     using (var sw = new StreamWriter(textStream))
     {
         input
         .ToStreamMessageObservable()
         .SynchronousForEach(message =>
         {
             var bv = message.bitvector.col;
             for (int i = 0; i < message.Count; i++)
             {
                 if ((bv[i >> 6] & (1L << (i & 0x3f))) == 0)
                 {
                     sw.WriteLine("{0}\t{1}\t{2}\t{3}", message.vsync.col[i], message.vother.col[i], message.key.col[i], message[i]);
                 }
             }
             message.Free();
         });
     }
 }
示例#3
0
 public static void Print <TKey, TPayload>(this IStreamable <TKey, TPayload> input)
 {
     Invariant.IsNotNull(input, "input");
     input.ToStreamMessageObservable().ForEachAsync(b => b.Print()).Wait();
 }