public void GenerateRows(SHNReader reader) { object[] values = new object[this.ColumnCount]; for (uint i = 0; i < RecordCount; ++i) { uint RowLength = reader.ReadUInt16(); for (int j = 0; j < this.ColumnCount; ++j) { switch (((ShnColumn)this.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)this.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"); } } base.Rows.Add(values); } }
public void Load(SHNReader reader, ref int unkcount) { string caption = reader.ReadPaddedString(48); if (caption.Trim().Length < 2) { base.ColumnName = "Undefined " + unkcount.ToString(); ++unkcount; } else { base.ColumnName = caption; } this.TypeByte = (byte)reader.ReadUInt32(); this.DataType = GetType(this.TypeByte); this.Length = reader.ReadInt32(); }