public MimeMessageReader(Stream stream)
 {
     if (stream == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
     }
     this.reader           = new DelimittedStreamReader(stream);
     this.mimeHeaderReader = new MimeHeaderReader(this.reader.GetNextStream(CRLFCRLF));
 }
 public MimeMessageReader(Stream stream)
 {
     if (stream == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
     }
     this.reader = new DelimittedStreamReader(stream);
     this.mimeHeaderReader = new MimeHeaderReader(this.reader.GetNextStream(CRLFCRLF));
 }
        public bool ReadNextPart()
        {
            string preface = this.Preface;

            if (this.currentStream != null)
            {
                this.currentStream.Close();
                this.currentStream = null;
            }
            Stream nextStream = this.reader.GetNextStream(CRLFCRLF);

            if (nextStream == null)
            {
                return(false);
            }
            if (this.BlockRead(nextStream, this.scratch, 0, 2) == 2)
            {
                if ((this.scratch[0] == 13) && (this.scratch[1] == 10))
                {
                    if (this.mimeHeaderReader == null)
                    {
                        this.mimeHeaderReader = new MimeHeaderReader(nextStream);
                    }
                    else
                    {
                        this.mimeHeaderReader.Reset(nextStream);
                    }
                    return(true);
                }
                if (((this.scratch[0] == 0x2d) && (this.scratch[1] == 0x2d)) && ((this.BlockRead(nextStream, this.scratch, 0, 2) < 2) || ((this.scratch[0] == 13) && (this.scratch[1] == 10))))
                {
                    return(false);
                }
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeReaderTruncated")));
        }
        public bool ReadNextPart()
        {
            string content = Preface;

            if (currentStream != null)
            {
                currentStream.Close();
                currentStream = null;
            }

            Stream stream = reader.GetNextStream(CRLFCRLF);

            if (stream == null)
                return false;

            if (BlockRead(stream, scratch, 0, 2) == 2)
            {
                if (scratch[0] == '\r' && scratch[1] == '\n')
                {
                    if (mimeHeaderReader == null)
                        mimeHeaderReader = new MimeHeaderReader(stream);
                    else
                        mimeHeaderReader.Reset(stream);
                    return true;
                }
                else if (scratch[0] == '-' && scratch[1] == '-')
                {
                    int read = BlockRead(stream, scratch, 0, 2);

                    if (read < 2 || (scratch[0] == '\r' && scratch[1] == '\n'))
                        return false;
                }
            }

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.GetString(SR.MimeReaderTruncated)));
        }
 public bool ReadNextPart()
 {
     string preface = this.Preface;
     if (this.currentStream != null)
     {
         this.currentStream.Close();
         this.currentStream = null;
     }
     Stream nextStream = this.reader.GetNextStream(CRLFCRLF);
     if (nextStream == null)
     {
         return false;
     }
     if (this.BlockRead(nextStream, this.scratch, 0, 2) == 2)
     {
         if ((this.scratch[0] == 13) && (this.scratch[1] == 10))
         {
             if (this.mimeHeaderReader == null)
             {
                 this.mimeHeaderReader = new MimeHeaderReader(nextStream);
             }
             else
             {
                 this.mimeHeaderReader.Reset(nextStream);
             }
             return true;
         }
         if (((this.scratch[0] == 0x2d) && (this.scratch[1] == 0x2d)) && ((this.BlockRead(nextStream, this.scratch, 0, 2) < 2) || ((this.scratch[0] == 13) && (this.scratch[1] == 10))))
         {
             return false;
         }
     }
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeReaderTruncated")));
 }