protected override void ReadContent(LiteDB.ByteReader reader) { this.CollectionName = reader.ReadString(); this.FreeDataPageID = reader.ReadUInt32(); var uintCount = reader.ReadUInt32(); // read as uint (4 bytes) foreach (var index in this.Indexes) { index.Field = reader.ReadString(); index.HeadNode = reader.ReadPageAddress(); index.TailNode = reader.ReadPageAddress(); index.FreeIndexPageID = reader.ReadUInt32(); index.Unique = reader.ReadBoolean(); reader.ReadBoolean(); // IgnoreCase reader.ReadBoolean(); // TrimWhitespace reader.ReadBoolean(); // EmptyStringToNull reader.ReadBoolean(); // RemoveAccents } // be compatible with v2_beta var longCount = reader.ReadInt64(); this.DocumentCount = Math.Max(uintCount, longCount); }
/// <summary> /// Write a custom ReadBsonValue because BsonType changed from v6 to v7 /// </summary> private LiteDB.BsonValue ReadBsonValue(LiteDB.ByteReader reader, ushort length) { var type = reader.ReadByte(); // using numbers because BsonType changed switch (type) { case 1: return(LiteDB.BsonValue.Null); case 2: return(reader.ReadInt32()); case 3: return(reader.ReadInt64()); case 4: return(reader.ReadDouble()); case 5: return(reader.ReadString(length)); case 6: return(new LiteDB.BsonReader(false).ReadDocument(reader)); case 7: return(new LiteDB.BsonReader(false).ReadArray(reader)); case 8: return(reader.ReadBytes(length)); case 9: return(reader.ReadObjectId()); case 10: return(reader.ReadGuid()); case 11: return(reader.ReadBoolean()); case 12: return(reader.ReadDateTime()); case 13: return(reader.ReadDateTimeOffset(length)); case 0: return(LiteDB.BsonValue.MinValue); case 14: return(LiteDB.BsonValue.MaxValue); } throw new NotImplementedException(); }