Exemplo n.º 1
0
        public static ValueTask <FlushResult> ProcessBlock(TrackingPipeWriter writer, NettraceBlock block, CancellationToken token)
        {
            // Write opening tag
            writer.WriteByte((byte)Tags.BeginPrivateObject);

            WriteBlockHeader(writer, block.Type);

            var written = compress && CompressBlockHelper.WriteBlockAndPreamble(writer, block);

            if (!written)
            {
                written = decompress && DecompressBlockHelper.WriteBlockAndPreamble(writer, block);
            }
            if (!written)
            {
                WriteBlockBodyPreamble(writer, block);

                WriteBlockBody(writer, block.BlockBody);
            }

            // Write closing tag
            writer.WriteByte((byte)Tags.EndObject);

            return(writer.FlushAsync(token));
        }
Exemplo n.º 2
0
 private static void WriteBlockHeader(TrackingPipeWriter writer, NettraceType type)
 {
     if (compress)
     {
         CompressBlockHelper.WriteBlockHeader(writer, type);
     }
     else if (decompress)
     {
         DecompressBlockHelper.WriteBlockHeader(writer, type);
     }
     else
     {
         /*
          * [open tag]
          *  [nullreference tag]
          *  [type version]
          *  [minReader Version]
          *  [length of block name]
          *  [block name]
          * [close tag]
          */
         writer.WriteByte((byte)Tags.BeginPrivateObject);
         writer.WriteByte((byte)Tags.NullReference);
         writer.WriteInt(type.Version);
         writer.WriteInt(type.MinimumReaderVersion);
         writer.WriteInt(type.Name.Length);
         Encoding.UTF8.GetBytes(type.Name, writer);
         writer.WriteByte((byte)Tags.EndObject);
     }
 }