コード例 #1
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (offset < 0 || offset > buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(offset));
            }

            if (count < 0 || count > buffer.Length - offset)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            if (mReader == null)
            {
                throw new ObjectDisposedException(null);
            }

            var remaining = mLength - mOffset;

            if (count > remaining)
            {
                count = (int)remaining;
            }

            if (count == 0)
            {
                return(0);
            }

            var result = mReader.Read(buffer, offset, count);

            if (result <= 0 || result > count)
            {
                throw new InternalFailureException();
            }

            mOffset += result;
            return(result);
        }
コード例 #2
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (offset < 0 || offset > buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(offset));
            }

            if (count < 0 || count > buffer.Length - offset)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            var result = mReader.Read(buffer, offset, count);

            mPosition += result;
            return(result);
        }