예제 #1
0
        protected override void ReadContent(ByteReader reader)
        {
            var info = reader.ReadString(HEADER_INFO.Length);
            var ver  = reader.ReadByte();

            if (info != HEADER_INFO)
            {
                throw LiteException.InvalidDatabase();
            }
            if (ver != FILE_VERSION)
            {
                throw LiteException.InvalidDatabaseVersion(ver);
            }

            this.ChangeID        = reader.ReadUInt16();
            this.FreeEmptyPageID = reader.ReadUInt32();
            this.LastPageID      = reader.ReadUInt32();
            this.UserVersion     = reader.ReadUInt16();
            this.Password        = reader.ReadBytes(this.Password.Length);
            this.Salt            = reader.ReadBytes(this.Salt.Length);

            // read page collections references (position on end of page)
            var cols = reader.ReadByte();

            for (var i = 0; i < cols; i++)
            {
                this.CollectionPages.Add(reader.ReadString(), reader.ReadUInt32());
            }

            // use last page byte position for recovery mode only because i forgot to reserve area before collection names!
            // TODO: fix this in next change data structure
            reader.Position = BasePage.PAGE_SIZE - 1;
            this.Recovery   = reader.ReadBoolean();
        }