コード例 #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}'.");
            }
        }
コード例 #2
0
        private static CpkRow ReadRow(BinaryReaderX tableBr, BinaryReaderX stringBr, BinaryReaderX dataBr,
                                      IList <CpkColumnInfo> columns)
        {
            var row = new CpkRow();

            foreach (var column in columns)
            {
                if (column.Storage == CpkColumnStorage.Row)
                {
                    row.Add(column.Name, CpkValue.Read(column.Type, tableBr, stringBr, dataBr));
                    continue;
                }

                row.Add(column.Name, column.Value);
            }

            return(row);
        }