Пример #1
0
        protected void ReadCore(Stream stream, ReadOptions options)
        {
            this.stream  = stream;
            this.options = options;

            var reader = new BinaryReader(stream);

            stream.Seek(0, SeekOrigin.Begin);
            var fileHeader = reader.ReadValue <FileHeader>();

            this.tableIndexes = reader.ReadValues <TableIndex>(fileHeader.TableCount);
            this.version      = fileHeader.MagicValue;
            this.revision     = fileHeader.Revision;

            stream.Seek(fileHeader.StringResourcesOffset, SeekOrigin.Begin);
            StringResource.ReadHeader(reader);
            var fileHeaderStrings = StringResource.GetHeaderStrings();

            this.name            = fileHeaderStrings.GetString(fileHeader.Name);
            this.tables          = new CremaBinaryTableCollection(this, this.tableIndexes);
            this.typesHashValue  = fileHeaderStrings.GetString(fileHeader.TypesHashValue);
            this.tablesHashValue = fileHeaderStrings.GetString(fileHeader.TablesHashValue);
            this.tags            = fileHeaderStrings.GetString(fileHeader.Tags);

            for (var i = 0; i < this.tableIndexes.Length; i++)
            {
                var tableIndex = this.tableIndexes[i];
                var table      = this.ReadTable(reader, tableIndex.Offset);
                this.tables[i] = table;
            }
        }