public static void WriteUuid(ByteBuffer buffer, Guid data)
        {
            buffer.EnsureSize(FixedWidth.Uuid);
            fixed (byte* d = &buffer.Buffer[buffer.End])
            {
                byte* p = (byte*)&data;
                d[0] = p[3];
                d[1] = p[2];
                d[2] = p[1];
                d[3] = p[0];

                d[4] = p[5];
                d[5] = p[4];

                d[6] = p[7];
                d[7] = p[6];

                *((ulong*)&d[8]) = *((ulong*)&p[8]);
            }

            buffer.Append(FixedWidth.Uuid);
        }
        public static void WriteDouble(ByteBuffer buffer, double data)
        {
            buffer.EnsureSize(FixedWidth.Double);
            fixed (byte* d = &buffer.Buffer[buffer.End])
            {
                byte* p = (byte*)&data;
                d[0] = p[7];
                d[1] = p[6];
                d[2] = p[5];
                d[3] = p[4];
                d[4] = p[3];
                d[5] = p[2];
                d[6] = p[1];
                d[7] = p[0];
            }

            buffer.Append(FixedWidth.Double);
        }
        public static void WriteFloat(ByteBuffer buffer, float data)
        {
            buffer.EnsureSize(FixedWidth.Float);
            fixed (byte* d = &buffer.Buffer[buffer.End])
            {
                byte* p = (byte*)&data;
                d[0] = p[3];
                d[1] = p[2];
                d[2] = p[1];
                d[3] = p[0];
            }

            buffer.Append(FixedWidth.Float);
        }
        public static void WriteUShort(ByteBuffer buffer, ushort data)
        {
            buffer.EnsureSize(FixedWidth.UShort);
            fixed (byte* d = &buffer.Buffer[buffer.End])
            {
                byte* p = (byte*)&data;
                d[0] = p[1];
                d[1] = p[0];
            }

            buffer.Append(FixedWidth.UShort);
        }
 public static void WriteUByte(ByteBuffer buffer, byte data)
 {
     buffer.EnsureSize(FixedWidth.UByte);
     buffer.Buffer[buffer.End] = data;
     buffer.Append(FixedWidth.UByte);
 }
Exemple #6
0
        static void Encode(AmqpSymbol value, int width, ByteBuffer buffer)
        {
            int stringSize = Encoding.ASCII.GetByteCount(value.Value);
            if (width == 0)
            {
                width = AmqpEncoding.GetEncodeWidthBySize(stringSize);
            }

            if (width == FixedWidth.UByte)
            {
                AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol8);
                AmqpBitConverter.WriteUByte(buffer, (byte)stringSize);
            }
            else
            {
                AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol32);
                AmqpBitConverter.WriteUInt(buffer, (uint)stringSize);
            }

            buffer.EnsureSize(stringSize);
            int written = Encoding.ASCII.GetBytes(value.Value, 0, value.Value.Length, buffer.Buffer, buffer.End);
            buffer.Append(written);
        }