예제 #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(int maxSize, out byte flags, out byte[] info)
        {
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            DiagnosticContext.Shared.ExtractInfo(buffer, maxSize, out info);
            flags = (byte)(2 | (DiagnosticContext.overFlow ? 1 : 0));
        }
예제 #3
0
        private static void FlushHeadRecord(BipBuffer buf)
        {
            byte b;

            buf.Extract(3, out b);
            int num = (b >> 4) * 8;

            buf.Release(num - 4);
            DiagnosticContext.overFlow = true;
        }
예제 #4
0
        public static byte[] PackInfo()
        {
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            byte[] array = new byte[DiagnosticContext.ContextBuffer.StructSize + buffer.AllocatedSize];
            int    num   = 0;

            DiagnosticContext.PackInfo(array, ref num, array.Length);
            return(array);
        }
예제 #5
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);
            }
예제 #6
0
        public static void Reset()
        {
            if (DiagnosticContext.DiagnosticContextTest != null)
            {
                DiagnosticContext.DiagnosticContextTest.Reset();
            }
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            DiagnosticContext.Shared.Reset(buffer);
            DiagnosticContext.overFlow = false;
        }
예제 #7
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;
 }
예제 #8
0
        private static BipBuffer GetBuffer()
        {
            BipBuffer bipBuffer = DiagnosticContext.bipBuffer;

            if (bipBuffer == null)
            {
                bipBuffer = (DiagnosticContext.bipBuffer = new BipBuffer(2048));
                DiagnosticContext.overFlow     = false;
                DiagnosticContext.stringBuffer = new byte[104];
            }
            return(bipBuffer);
        }
예제 #9
0
 public static void Reset(BipBuffer buf)
 {
     buf.Release(buf.AllocatedSize);
 }
예제 #10
0
        private static void GetBufferPointer(int size, out byte[] buffer, out int index)
        {
            BipBuffer buffer2 = DiagnosticContext.GetBuffer();

            DiagnosticContext.Shared.GetBufferPointer(buffer2, size, out buffer, out index);
        }