Пример #1
0
        private static CpkColumnInfo ReadColumn(BinaryReaderX tableBr, BinaryReaderX stringBr, BinaryReaderX dataBr)
        {
            // Read column info
            var flags      = tableBr.ReadByte();
            var nameOffset = tableBr.ReadInt32();

            // Resolve final information
            var name    = CpkSupport.ReadString(stringBr, nameOffset);
            var storage = (CpkColumnStorage)(flags >> 4);
            var type    = (CpkDataType)(flags & 0xF);

            switch (storage)
            {
            case CpkColumnStorage.Const:
                return(CpkColumnInfo.CreateConst(name, CpkValue.Read(type, tableBr, stringBr, dataBr)));

            case CpkColumnStorage.Default:
                return(CpkColumnInfo.CreateZero(name, type));

            case CpkColumnStorage.Row:
                return(CpkColumnInfo.CreateRow(name, type));

            default:
                throw new InvalidOperationException($"Unknown storage type '{storage}'.");
            }
        }