private CremaBinaryTable ReadTable(BinaryReader reader, long offset) { TableHeader tableHeader; TableInfo tableInfo; reader.Seek(offset, SeekOrigin.Begin); reader.ReadValue(out tableHeader); reader.Seek(tableHeader.TableInfoOffset + offset, SeekOrigin.Begin); reader.ReadValue(out tableInfo); var table = new CremaBinaryTable(this, tableInfo.RowCount, this.options); reader.Seek(tableHeader.StringResourcesOffset + offset, SeekOrigin.Begin); StringResource.Read(reader); reader.Seek(tableHeader.ColumnsOffset + offset, SeekOrigin.Begin); this.ReadColumns(reader, table, tableInfo.ColumnCount); reader.Seek(tableHeader.RowsOffset + offset, SeekOrigin.Begin); this.ReadRows(reader, table, tableInfo.RowCount); table.Name = StringResource.GetString(tableInfo.TableName); table.Category = StringResource.GetString(tableInfo.CategoryName); table.HashValue = StringResource.GetString(tableHeader.HashValue); return(table); }
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.Read(reader); this.name = StringResource.GetString(fileHeader.Name); this.tables = new CremaBinaryTableCollection(this, this.tableIndexes); this.typesHashValue = StringResource.GetString(fileHeader.TypesHashValue); this.tablesHashValue = StringResource.GetString(fileHeader.TablesHashValue); this.tags = StringResource.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; } }