Esempio n. 1
0
        public virtual void Disassemble(Action <TagItem> callback)
        {
            if (_input.IsDisposed)
            {
                throw new ObjectDisposedException(nameof(_input), "Input stream has already been disposed, or disassembly of the file has already occured.");
            }
            long position = (8 + Frame.Area.GetByteSize() + 4);

            while (position != FileLength)
            {
                var header = new HeaderRecord(_input);
                position += (header.IsLongTag ? 6 : 2);
                long offset = (header.Length + position);

                TagItem tag = ReadTag(header, _input);
                position += tag.GetBodySize();

                if (position != offset)
                {
                    throw new IOException($"Expected position value '{offset}', instead got '{position}'.");
                }
                callback?.Invoke(tag);
                Tags.Add(tag);

                if (tag.Kind == TagKind.End)
                {
                    break;
                }
            }
            _input.Dispose();
        }
Esempio n. 2
0
        public virtual void Disassemble(Action <TagItem> callback)
        {
            long position = (8 + Frame.Area.GetByteSize() + 4);

            while (position != FileLength)
            {
                var header = new HeaderRecord(_input);
                position += (header.IsLongTag ? 6 : 2);
                long offset = (header.Length + position);

                TagItem tag = ReadTag(header, _input);
                position += tag.GetBodySize();

                if (position != offset)
                {
                    throw new IOException($"Expected position value '{offset}', instead got '{position}'.");
                }
                callback?.Invoke(tag);
                Tags.Add(tag);

                if (tag.Kind == TagKind.End)
                {
                    FileLength = (uint)position;
                    break;
                }
            }
        }