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); }
public static int GetEncodeSize(ArraySegment <byte> value) { if (value.Array == null) { return(1); } return(1 + AmqpEncoding.GetEncodeWidthBySize(value.Count) + value.Count); }
public static int GetEncodeSize(AmqpSymbol value) { if (value.Value == null) { return(1); } return(1 + AmqpEncoding.GetEncodeWidthBySize(value.ValueSize) + value.ValueSize); }
public static int GetEncodeSize(string value) { if (value == null) { return(1); } int byteCount = System.Text.Encoding.UTF8.GetByteCount(value); return(1 + AmqpEncoding.GetEncodeWidthBySize(byteCount) + byteCount); }
public static int GetEncodeSize(string value) { if (value == null) { return(FixedWidth.NullEncoded); } int stringSize = Encoding.UTF8.GetByteCount(value); return(FixedWidth.FormatCode + AmqpEncoding.GetEncodeWidthBySize(stringSize) + stringSize); }
public static void Encode(string value, ByteBuffer buffer) { if (value == null) { AmqpEncoding.EncodeNull(buffer); return; } byte[] bytes = System.Text.Encoding.UTF8.GetBytes(value); int encodeWidthBySize = AmqpEncoding.GetEncodeWidthBySize((int)bytes.Length); AmqpBitConverter.WriteUByte(buffer, (byte)((encodeWidthBySize == 1 ? 161 : 177))); StringEncoding.Encode(bytes, encodeWidthBySize, buffer); }
public static void Encode(AmqpSymbol value, ByteBuffer buffer) { if (value.Value == null) { AmqpEncoding.EncodeNull(buffer); return; } byte[] bytes = System.Text.Encoding.ASCII.GetBytes(value.Value); int encodeWidthBySize = AmqpEncoding.GetEncodeWidthBySize((int)bytes.Length); AmqpBitConverter.WriteUByte(buffer, (byte)((encodeWidthBySize == 1 ? 163 : 179))); SymbolEncoding.Encode(bytes, encodeWidthBySize, buffer); }
public static void Encode(ArraySegment <byte> value, ByteBuffer buffer) { if (value.Array == null) { AmqpEncoding.EncodeNull(buffer); return; } if (AmqpEncoding.GetEncodeWidthBySize(value.Count) != 1) { AmqpBitConverter.WriteUByte(buffer, 176); AmqpBitConverter.WriteUInt(buffer, (uint)value.Count); } else { AmqpBitConverter.WriteUByte(buffer, 160); AmqpBitConverter.WriteUByte(buffer, (byte)value.Count); } AmqpBitConverter.WriteBytes(buffer, value.Array, value.Offset, value.Count); }
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, (byte)FormatCode.Binary8); AmqpBitConverter.WriteUByte(buffer, (byte)value.Count); } else { AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Binary32); AmqpBitConverter.WriteUInt(buffer, (uint)value.Count); } buffer.WriteBytes(value.Array, value.Offset, value.Count); } }
public static int GetEncodeSize(AmqpSymbol value) { return(value.Value == null ? FixedWidth.NullEncoded : FixedWidth.FormatCode + AmqpEncoding.GetEncodeWidthBySize(value.ValueSize) + value.ValueSize); }
public static int GetEncodeSize(ArraySegment <byte> value) { return(value.Array == null ? FixedWidth.NullEncoded : FixedWidth.FormatCode + AmqpEncoding.GetEncodeWidthBySize(value.Count) + value.Count); }