コード例 #1
0
        /// <summary>
        /// Writes a uuid (16-bytes) into the buffer and advance the buffer write cursor.
        /// </summary>
        /// <param name="buffer">The buffer to write.</param>
        /// <param name="data">The data to write.</param>
        public static void WriteUuid(ByteBuffer buffer, Guid data)
        {
            buffer.ValidateWrite(FixedWidth.Uuid);
            byte[] p   = data.ToByteArray();
            int    pos = buffer.WritePos;

            if (AmqpBitConverter.IsLittleEndian)
            {
                buffer.Buffer[pos++] = p[3];
                buffer.Buffer[pos++] = p[2];
                buffer.Buffer[pos++] = p[1];
                buffer.Buffer[pos++] = p[0];

                buffer.Buffer[pos++] = p[5];
                buffer.Buffer[pos++] = p[4];

                buffer.Buffer[pos++] = p[7];
                buffer.Buffer[pos++] = p[6];

                Array.Copy(p, 8, buffer.Buffer, pos, 8);
            }
            else
            {
                Array.Copy(p, buffer.Buffer, FixedWidth.Uuid);
            }

            buffer.Append(FixedWidth.Uuid);
        }
コード例 #2
0
 /// <summary>
 /// Writes a 16-bit signed integer into the buffer and advance the buffer write cursor.
 /// </summary>
 /// <param name="buffer">The buffer to write.</param>
 /// <param name="data">The data to write.</param>
 public static void WriteShort(ByteBuffer buffer, short data)
 {
     buffer.ValidateWrite(FixedWidth.Short);
     buffer.Buffer[buffer.WritePos]     = (byte)(data >> 8);
     buffer.Buffer[buffer.WritePos + 1] = (byte)data;
     buffer.Append(FixedWidth.Short);
 }
コード例 #3
0
 /// <summary>
 /// Writes bytes from one buffer into another.
 /// </summary>
 /// <param name="buffer">The destination buffer.</param>
 /// <param name="data">The source buffer</param>
 /// <param name="offset">The position in source buffer to start.</param>
 /// <param name="count">The number of bytes to write.</param>
 public static void WriteBytes(ByteBuffer buffer, byte[] data, int offset, int count)
 {
     buffer.ValidateWrite(count);
     Array.Copy(data, offset, buffer.Buffer, buffer.WritePos, count);
     buffer.Append(count);
 }
コード例 #4
0
 /// <summary>
 /// Writes a 32-bit signed integer into the buffer and advance the buffer write cursor.
 /// </summary>
 /// <param name="buffer">The buffer to write.</param>
 /// <param name="data">The data to write.</param>
 public static void WriteInt(ByteBuffer buffer, int data)
 {
     buffer.ValidateWrite(FixedWidth.Int);
     WriteInt(buffer.Buffer, buffer.WritePos, data);
     buffer.Append(FixedWidth.Int);
 }
コード例 #5
0
 /// <summary>
 /// Writes a signed byte into the buffer and advance the buffer write cursor.
 /// </summary>
 /// <param name="buffer">The buffer to write.</param>
 /// <param name="data">The data to write.</param>
 public static void WriteByte(ByteBuffer buffer, sbyte data)
 {
     buffer.ValidateWrite(FixedWidth.Byte);
     buffer.Buffer[buffer.WritePos] = (byte)data;
     buffer.Append(FixedWidth.Byte);
 }