WriteBytes() public static method

public static WriteBytes ( System.ByteBuffer buffer, byte data, int offset, int count ) : void
buffer System.ByteBuffer
data byte
offset int
count int
return void
示例#1
0
 public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer)
 {
     if (arrayEncoding)
     {
         ArraySegment <byte> binaryValue = (ArraySegment <byte>)value;
         AmqpBitConverter.WriteUInt(buffer, (uint)binaryValue.Count);
         AmqpBitConverter.WriteBytes(buffer, binaryValue.Array, binaryValue.Offset, binaryValue.Count);
     }
     else
     {
         BinaryEncoding.Encode((ArraySegment <byte>)value, buffer);
     }
 }
示例#2
0
        static void Encode(byte[] encodedData, int width, ByteBuffer buffer)
        {
            if (width == FixedWidth.UByte)
            {
                AmqpBitConverter.WriteUByte(buffer, (byte)encodedData.Length);
            }
            else
            {
                AmqpBitConverter.WriteUInt(buffer, (uint)encodedData.Length);
            }

            AmqpBitConverter.WriteBytes(buffer, encodedData, 0, encodedData.Length);
        }
示例#3
0
        internal static unsafe void EncodeValue(decimal value, ByteBuffer buffer)
        {
            int[] bits              = Decimal.GetBits(value);
            int   lowSignificant    = bits[0];
            int   middleSignificant = bits[1];
            int   highSignificant   = bits[2];
            int   signAndExponent   = bits[3];

            byte[] bytes    = new byte[FixedWidth.Decimal128];
            byte * p        = (byte *)&signAndExponent;
            int    exponent = Decimal128Bias - p[2];

            bytes[0]  = p[3];                           // sign
            bytes[0] |= (byte)(exponent >> 9);          // 7 bits in msb
            bytes[1]  = (byte)((exponent & 0x7F) << 1); // 7 bits in 2nd msb
            bytes[2]  = 0;
            bytes[3]  = 0;

            p        = (byte *)&highSignificant;
            bytes[4] = p[3];
            bytes[5] = p[2];
            bytes[6] = p[1];
            bytes[7] = p[0];

            p         = (byte *)&middleSignificant;
            bytes[8]  = p[3];
            bytes[9]  = p[2];
            bytes[10] = p[1];
            bytes[11] = p[0];

            p         = (byte *)&lowSignificant;
            bytes[12] = p[3];
            bytes[13] = p[2];
            bytes[14] = p[1];
            bytes[15] = p[0];

            AmqpBitConverter.WriteBytes(buffer, bytes, 0, bytes.Length);
        }
示例#4
0
        public static void Encode(ArraySegment <byte> value, ByteBuffer buffer)
        {
            if (value.Array == null)
            {
                AmqpEncoding.EncodeNull(buffer);
            }
            else
            {
                int width = AmqpEncoding.GetEncodeWidthBySize(value.Count);
                if (width == FixedWidth.UByte)
                {
                    AmqpBitConverter.WriteUByte(buffer, FormatCode.Binary8);
                    AmqpBitConverter.WriteUByte(buffer, (byte)value.Count);
                }
                else
                {
                    AmqpBitConverter.WriteUByte(buffer, FormatCode.Binary32);
                    AmqpBitConverter.WriteUInt(buffer, (uint)value.Count);
                }

                AmqpBitConverter.WriteBytes(buffer, value.Array, value.Offset, value.Count);
            }
        }