private void ReadInfoChunk(byte[] InData) { Chunks = new List <ListChunk>(); var dataReader = new BinaryReader(new MemoryStream(InData), Encoding.ASCII); while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = new String(dataReader.ReadChars(4)); uint size = dataReader.ReadUInt32(); if (size % 2 != 0) // account for padding { size += 1; } byte[] ChunkData = dataReader.ReadBytes((int)size); LabeledListChunk newChunk; switch (type) { case LiCkInfoType.TCDO: newChunk = new LiCkInfoTCDO(ChunkData) { ID = type }; break; case LiCkInfoType.TCOD: newChunk = new LiCkInfoTCOD(ChunkData) { ID = type }; break; default: newChunk = new LiCkInfoString(ChunkData) { ID = type }; break; } Chunks.Add(newChunk); } }
private void ReadInfoChunk(byte[] InData) { Chunks = new List<ListChunk>(); var dataReader = new BinaryReader(new MemoryStream(InData), Encoding.ASCII); while (dataReader.BaseStream.Position < dataReader.BaseStream.Length) { var type = new String(dataReader.ReadChars(4)); uint size = dataReader.ReadUInt32(); if (size%2 != 0) // account for padding size += 1; byte[] ChunkData = dataReader.ReadBytes((int) size); LabeledListChunk newChunk; switch (type) { case LiCkInfoType.TCDO: newChunk = new LiCkInfoTCDO(ChunkData) {ID = type}; break; case LiCkInfoType.TCOD: newChunk = new LiCkInfoTCOD(ChunkData) {ID = type}; break; default: newChunk = new LiCkInfoString(ChunkData) {ID = type}; break; } Chunks.Add(newChunk); } }