Beispiel #1
0
        private void ReadTableSchemas(BinaryReader reader)
        {
            int tableCount = reader.ReadInt32();

            tables = new Dictionary <string, Table>(tableCount);

            for (int i = 0; i < tableCount; i++)
            {
                int nameIndex = reader.ReadInt32();
                int rowCount  = reader.ReadInt32();
                int rowLength = reader.ReadInt32();

                string name = GetString(nameIndex);

                int offset      = 0;
                int columnCount = reader.ReadInt32();
                Dictionary <string, Column> columns = new Dictionary <string, Column>(columnCount);
                for (int j = 0; j < columnCount; j++)
                {
                    int  columnNameIndex = reader.ReadInt32();
                    byte dataType        = reader.ReadByte();

                    string     columnName = GetString(columnNameIndex);
                    ColumnType type       = (ColumnType)dataType;

                    var column = new Column(columnName, type, offset);
                    columns[columnName] = column;

                    offset += LiteData.GetLength(type);
                }

                int    length    = reader.ReadInt32();
                byte[] tableData = reader.ReadBytes(length);

                var table = new Table(name, columns, rowLength, rowCount, tableData);
                tables.Add(name, table);
            }
        }
Beispiel #2
0
            public float ReadSingle(int columnIndex)
            {
                var column = columns[columnIndex];

                return(column != null?LiteData.ReadSingle(data, offset + column.Offset, column.Type, stringTable) : 0.0f);
            }
Beispiel #3
0
            public string ReadString(int columnIndex)
            {
                var column = columns[columnIndex];

                return(column != null?LiteData.ReadString(data, offset + column.Offset, column.Type, stringTable) : null);
            }
Beispiel #4
0
            public int ReadInt32(int columnIndex)
            {
                var column = columns[columnIndex];

                return(column != null?LiteData.ReadInt32(data, offset + column.Offset, column.Type, stringTable) : 0);
            }