Esempio n. 1
0
        internal RiffList(Stream target, String listId, String chunkId) // write mode
        {
            _baseChunk = new RiffChunk(null, target, chunkId);

            if (listId.Length != 4)
            {
                throw new ArgumentException("listID must be 4 characters in length");
            }

            _listId = listId;

            _baseChunk.WriteByte((byte)_listId[0]);
            _baseChunk.WriteByte((byte)_listId[1]);
            _baseChunk.WriteByte((byte)_listId[2]);
            _baseChunk.WriteByte((byte)_listId[3]);
        }
Esempio n. 2
0
        internal RiffList(RiffChunk chunk, string expectedChunkId) // read mode
        {
            if (chunk == null)
            {
                throw new ArgumentNullException("chunk");
            }

            _baseChunk = chunk;
            if (_baseChunk.ChunkId != expectedChunkId)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          "chunk must be a {0} chunk", expectedChunkId));
            }

            byte[] b = _baseChunk.ReadBytes(4);

            _listId = new string(new[] { (char)b[0], (char)b[1], (char)b[2], (char)b[3] });

            _chunks = Descendants();
        }