public static byte[] ReadLongstr(NetworkBinaryReader reader) { uint byteCount = reader.ReadUInt32(); if (byteCount > int.MaxValue) { throw new SyntaxError("Long string too long; " + "byte length=" + byteCount + ", max=" + int.MaxValue); } return reader.ReadBytes((int)byteCount); }
public static IList ReadArray(NetworkBinaryReader reader) { IList array = new ArrayList(); long arrayLength = reader.ReadUInt32(); Stream backingStream = reader.BaseStream; long startPosition = backingStream.Position; while ((backingStream.Position - startPosition) < arrayLength) { object value = ReadFieldValue(reader); array.Add(value); } return array; }
///<summary>Reads an AMQP "table" definition from the reader.</summary> ///<remarks> /// Supports the AMQP 0-8/0-9 standard entry types S, I, D, T /// and F, as well as the QPid-0-8 specific b, d, f, l, s, t, /// x and V types and the AMQP 0-9-1 A type. ///</remarks> public static IDictionary ReadTable(NetworkBinaryReader reader) { Hashtable table = new Hashtable(); long tableLength = reader.ReadUInt32(); Stream backingStream = reader.BaseStream; long startPosition = backingStream.Position; while ((backingStream.Position - startPosition) < tableLength) { string key = ReadShortstr(reader); object value = ReadFieldValue(reader); if (!table.ContainsKey(key)) { table[key] = value; } } return table; }
public static uint ReadLong(NetworkBinaryReader reader) { return reader.ReadUInt32(); }
///<summary>Reads an AMQP "table" definition from the reader.</summary> ///<remarks> /// Supports the AMQP 0-8/0-9 standard entry types S, I, D, T /// and F, as well as the QPid-0-8 specific b, d, f, l, s, t, /// x and V types. ///</remarks> public static IDictionary ReadTable(NetworkBinaryReader reader) { Hashtable table = new Hashtable(); long tableLength = reader.ReadUInt32(); Stream backingStream = reader.BaseStream; long startPosition = backingStream.Position; while ((backingStream.Position - startPosition) < tableLength) { string key = ReadShortstr(reader); object value = null; byte discriminator = reader.ReadByte(); switch ((char)discriminator) { case 'S': value = ReadLongstr(reader); break; case 'I': value = reader.ReadInt32(); break; case 'D': value = ReadDecimal(reader); break; case 'T': value = ReadTimestamp(reader); break; case 'F': value = ReadTable(reader); break; case 'b': value = ReadOctet(reader); break; case 'd': value = reader.ReadDouble(); break; case 'f': value = reader.ReadSingle(); break; case 'l': value = reader.ReadInt64(); break; case 's': value = reader.ReadInt16(); break; case 't': value = (ReadOctet(reader) != 0); break; case 'x': value = new BinaryTableValue(ReadLongstr(reader)); break; case 'V': value = null; break; default: throw new SyntaxError("Unrecognised type in table: " + (char) discriminator); } if (!table.ContainsKey(key)) { table[key] = value; } } return table; }