예제 #1
0
파일: CkList.cs 프로젝트: teetow/teevegas
        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);
            }
        }
예제 #2
0
파일: CkList.cs 프로젝트: teetow/teevegas
		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);
			}
		}