Ejemplo n.º 1
0
        public CremaBinaryTable ReadTable(string tableName)
        {
            int index = -1;

            for (int i = 0; i < this.tableIndexes.Length; i++)
            {
                TableIndex tableIndex = this.tableIndexes[i];

                if (StringResource.Equals(tableIndex.TableName, tableName) == true)
                {
                    index = i;
                    break;
                }
            }

            if (index == -1)
            {
                throw new KeyNotFoundException("테이블을 찾을수 없습니다.");
            }

            CremaBinaryTable table = this.ReadTable(new BinaryReader(this.stream), this.tableIndexes[index].Offset);

            this.tables[index] = table;
            return(table);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private void ReadColumns(BinaryReader reader, CremaBinaryTable table, int columnCount)
        {
            var keys         = new List <IColumn>();
            var columns      = new CremaBinaryColumnCollection(table, columnCount, this.CaseSensitive);
            var tableStrings = StringResource.GetTableStrings(table);

            for (var i = 0; i < columnCount; i++)
            {
                var columninfo = reader.ReadValue <ColumnInfo>();
                var columnName = tableStrings.GetString(columninfo.ColumnName);
                var typeName   = tableStrings.GetString(columninfo.DataType);
                var isKey      = columninfo.Iskey == 0 ? false : true;

                var column = new CremaBinaryColumn(columnName, Utility.NameToType(typeName), isKey);
                columns.Add(column);
                if (isKey == true)
                {
                    keys.Add(column);
                }

                column.Table = table;
            }
            table.Columns = columns;
            table.Keys    = keys.ToArray();
        }
Ejemplo n.º 4
0
        public CremaBinaryTable ReadTable(int index)
        {
            TableIndex       table_index = this.tableIndexes[index];
            CremaBinaryTable table       = this.ReadTable(new BinaryReader(this.stream), table_index.Offset);

            this.tables[index] = table;
            return(table);
        }
Ejemplo n.º 5
0
 public CremaBinaryRowCollection(CremaBinaryTable table, int rowCount)
 {
     this.table = table;
     this.rows  = new List <CremaBinaryRow>(rowCount);
     for (int i = 0; i < rowCount; i++)
     {
         this.rows.Add(new CremaBinaryRow());
     }
 }
Ejemplo n.º 6
0
 private void ReadRows(BinaryReader reader, CremaBinaryTable table, int rowCount)
 {
     for (var i = 0; i < rowCount; i++)
     {
         var dataRow = table.Rows[i];
         var length  = reader.ReadInt32();
         dataRow.fieldbytes = reader.ReadBytes(length);
         dataRow.Table      = table;
     }
 }
Ejemplo n.º 7
0
 public CremaBinaryColumnCollection(CremaBinaryTable table, int capacity, bool caseSensitive)
 {
     this.table   = table;
     this.columns = new OrderedDictionary(capacity, StringResource.GetComparer(caseSensitive));
 }