示例#1
0
        public unsafe static int PackInfo(byte[] destinationBuffer, ref int pos, int maxSize)
        {
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            if (maxSize < DiagnosticContext.ContextBuffer.StructSize)
            {
                return(0);
            }
            while (maxSize < DiagnosticContext.Size)
            {
                DiagnosticContext.FlushHeadRecord(buffer);
            }

            fixed(byte *ptr = &destinationBuffer[pos])
            {
                DiagnosticContext.ContextBuffer *ptr2 = (DiagnosticContext.ContextBuffer *)ptr;
                ptr2->Format    = byte.MaxValue;
                ptr2->ThreadID  = (uint)Environment.CurrentManagedThreadId;
                ptr2->RequestID = 0U;
                ptr2->Flags     = (byte)(2 | (DiagnosticContext.overFlow ? 1 : 0));
                ptr2->Length    = (uint)buffer.AllocatedSize;
            }

            pos     += DiagnosticContext.ContextBuffer.StructSize;
            maxSize -= DiagnosticContext.ContextBuffer.StructSize;
            int allocatedSize = buffer.AllocatedSize;

            buffer.Extract(destinationBuffer, pos, allocatedSize);
            pos += allocatedSize;
            return(allocatedSize + DiagnosticContext.ContextBuffer.StructSize);
        }
示例#2
0
            public static void ExtractInfo(BipBuffer buf, int maxSize, out byte[] info)
            {
                while (maxSize < buf.AllocatedSize)
                {
                    DiagnosticContext.FlushHeadRecord(buf);
                }
                int allocatedSize = buf.AllocatedSize;

                info = new byte[allocatedSize];
                buf.Extract(info, 0, allocatedSize);
            }
示例#3
0
 public static void GetBufferPointer(BipBuffer buf, int size, out byte[] buffer, out int index)
 {
     do
     {
         index = buf.Allocate(size);
         if (-1 == index)
         {
             DiagnosticContext.FlushHeadRecord(buf);
         }
     }while (-1 == index);
     buffer = buf.Buffer;
 }