Beispiel #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));
        }
 static public void WriteBlockHeader(TrackingPipeWriter writer, NettraceType type)
 {
     /*
      * [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);
     if (type.Name == KnownTypeNames.EventBlock)
     {
         writer.WriteInt(KnownTypeNames.EventBlockCompressed.Length);
         Encoding.UTF8.GetBytes(KnownTypeNames.EventBlockCompressed, writer);
     }
     else if (type.Name == KnownTypeNames.StackBlock)
     {
         writer.WriteInt(KnownTypeNames.StackBlockCompressed.Length);
         Encoding.UTF8.GetBytes(KnownTypeNames.StackBlockCompressed, writer);
     }
     else
     {
         writer.WriteInt(type.Name.Length);
         Encoding.UTF8.GetBytes(type.Name, writer);
     }
     writer.WriteByte((byte)Tags.EndObject);
 }
Beispiel #3
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);
     }
 }