public override int Read(byte[] buffer, int offset, int count)
        {
            byte[] buf;
            int    nread;

            if (stream == null)
            {
                throw new ObjectDisposedException("GMimeStream", "The backing stream has been closed.");
            }

            if (offset > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("offset");
            }

            if (offset + count > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            if (offset != 0)
            {
                buf = new byte [count];
            }
            else
            {
                buf = buffer;
            }

            nread = (int)stream.Read(buf, (uint)count);

            if (nread < 0)
            {
                throw new IOException();
            }

            if (buf != buffer && nread > 0)
            {
                Array.Copy(buf, 0, buffer, offset, nread);
            }

            return(nread);
        }