Exemple #1
0
        public void GenerateColumns(SHNReader reader)
        {
            var unkcolumns = 0;
            var Length     = 2;

            for (var i = 0; i < ColumnCount; ++i)
            {
                var col = new ShnColumn();
                col.Load(reader, ref unkcolumns);
                Length += col.Length;
                Columns.Add(col);
            }

            if (Length != DefaultRecordLength)
            {
                throw new Exception("Default record Length does not fit.");
            }
        }
Exemple #2
0
        public void GenerateRows(SHNReader reader)
        {
            var values = new object[ColumnCount];

            for (uint i = 0; i < RecordCount; ++i)
            {
                uint RowLength = reader.ReadUInt16();
                for (var j = 0; j < ColumnCount; ++j)
                {
                    switch (((ShnColumn)Columns[j]).TypeByte)
                    {
                    case 1:
                    case 12:
                    case 16:
                        values[j] = reader.ReadByte();
                        break;

                    case 2:
                        values[j] = reader.ReadUInt16();
                        break;

                    case 3:
                    case 11:
                    case 18:
                    case 27:
                        values[j] = reader.ReadUInt32();
                        break;

                    case 5:
                        values[j] = reader.ReadSingle();
                        break;

                    case 9:
                    case 24:
                        values[j] = reader.ReadPaddedString(((ShnColumn)Columns[j]).Length);
                        break;

                    case 13:
                    case 21:
                        values[j] = reader.ReadInt16();
                        break;

                    case 20:
                        values[j] = reader.ReadSByte();
                        break;

                    case 22:
                        values[j] = reader.ReadInt32();
                        break;

                    case 26
                        :     // TODO: Should be read until first null byte, to support more than 1 this kind of column
                        values[j] = reader.ReadPaddedString((int)(RowLength - DefaultRecordLength + 1));
                        break;

                    default:
                        throw new Exception("New column type found");
                    }
                }

                Rows.Add(values);
            }
        }