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 GetValueSize(AmqpSymbol value) { if (value.Value == null) { return(0); } return(System.Text.Encoding.ASCII.GetByteCount(value.Value)); }
public static int GetEncodeSize(AmqpSymbol value) { if (value.Value == null) { return(1); } return(1 + AmqpEncoding.GetEncodeWidthBySize(value.ValueSize) + value.ValueSize); }
public static void Encode(AmqpSymbol value, ByteBuffer buffer) { if (value.Value == null) { AmqpEncoding.EncodeNull(buffer); } else { SymbolEncoding.Encode(value, 0, buffer); } }
public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer) { if (!arrayEncoding) { SymbolEncoding.Encode((AmqpSymbol)value, buffer); return; } System.Text.Encoding aSCII = System.Text.Encoding.ASCII; AmqpSymbol amqpSymbol = (AmqpSymbol)value; SymbolEncoding.Encode(aSCII.GetBytes(amqpSymbol.Value), 4, 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 int GetEncodeSize(AmqpSymbol value) { return(value.Value == null ? FixedWidth.NullEncoded : FixedWidth.FormatCode + AmqpEncoding.GetEncodeWidthBySize(value.ValueSize) + value.ValueSize); }
public static int GetValueSize(AmqpSymbol value) { return(value.Value == null ? FixedWidth.Null : Encoding.ASCII.GetByteCount(value.Value)); }