static private ReadFormatCode ( System.ByteBuffer buffer ) : byte | ||
buffer | System.ByteBuffer | |
return | byte |
public void KnownString_UsedInEncoder() { try { WellknownStringDecoder decoder = new WellknownStringDecoder(); decoder.AddWellknownString("abc"); Encoder.StringDecoder = decoder; ByteBuffer buffer = new ByteBuffer(128, true); Encoder.WriteString(buffer, "abc", true); Encoder.WriteString(buffer, "abc", true); buffer.Seek(0); string decodedString1 = Encoder.ReadString(buffer, Encoder.ReadFormatCode(buffer)); string decodedString2 = Encoder.ReadString(buffer, Encoder.ReadFormatCode(buffer)); Assert.IsTrue(ReferenceEquals(decodedString1, decodedString2)); } finally { Encoder.StringDecoder = null; } }
internal override void DecodeValue(ByteBuffer buffer) { var list = Encoder.ReadList(buffer, Encoder.ReadFormatCode(buffer)); int count = list.Count < this.fields.Length ? list.Count : this.fields.Length; for (int i = 0; i < count; i++) { this.fields[i] = list[i]; } }
internal override void DecodeValue(ByteBuffer buffer) { byte formatCode = Encoder.ReadFormatCode(buffer); int size; int count; Encoder.ReadListCount(buffer, formatCode, out size, out count); for (int i = 0; i < count; i++) { formatCode = Encoder.ReadFormatCode(buffer); if (formatCode != FormatCode.Null) { this.ReadField(buffer, i, formatCode); this.fields |= (1 << i); } } }
public static Array ReadArray(ByteBuffer buffer, byte formatCode) { if (formatCode == FormatCode.Null) { return(null); } int size; int count; if (formatCode == FormatCode.Array8) { size = AmqpBitConverter.ReadUByte(buffer); count = AmqpBitConverter.ReadUByte(buffer); } else if (formatCode == FormatCode.Array32) { size = (int)AmqpBitConverter.ReadUInt(buffer); count = (int)AmqpBitConverter.ReadUInt(buffer); } else { throw DecodeException(formatCode, buffer.Offset); } formatCode = Encoder.ReadFormatCode(buffer); Serializer codec = GetSerializer(formatCode); if (codec == null) { throw DecodeException(formatCode, buffer.Offset); } Array value = Array.CreateInstance(codec.Type, count); IList list = value; for (int i = 0; i < count; ++i) { list[i] = codec.Decoder(buffer, formatCode); } return(value); }
public static object ReadObject(ByteBuffer buffer) { byte formatCode = Encoder.ReadFormatCode(buffer); return(ReadObject(buffer, formatCode)); }
internal override void DecodeValue(ByteBuffer buffer) { this.map = Encoder.ReadMap(buffer, Encoder.ReadFormatCode(buffer)); }