Amqp.Types.Encoder.WriteInt C# (CSharp) Method

WriteInt() public static method

Writes a signed 32-bit integer value to a buffer.
public static WriteInt ( System.ByteBuffer buffer, int value, bool smallEncoding ) : void
buffer System.ByteBuffer The buffer to write.
value int The signed 32-bit integer value.
smallEncoding bool if true, try using small encoding if possible.
return void
        public static void WriteInt(ByteBuffer buffer, int value, bool smallEncoding)
        {
            if (smallEncoding && value >= sbyte.MinValue && value <= sbyte.MaxValue)
            {
                AmqpBitConverter.WriteUByte(buffer, FormatCode.SmallInt);
                AmqpBitConverter.WriteByte(buffer, (sbyte)value);
            }
            else
            {
                AmqpBitConverter.WriteUByte(buffer, FormatCode.Int);
                AmqpBitConverter.WriteInt(buffer, value);
            }
        }