public static object ReadFieldValue(NetworkBinaryReader 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 'A': value = ReadArray(reader); break; case 'b': value = reader.ReadSByte(); 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); } return value; }