Example #1
0
 private void AssertGood(bool checkPositionedOnHeader)
 {
     if (this.reader == null)
     {
         throw new NotSupportedException(Strings.HeaderReaderNotInitialized);
     }
     this.reader.AssertGoodToUse(true, true);
     if (!MimeReader.StateIsOneOf(this.reader.ReaderState, MimeReaderState.PartStart | MimeReaderState.HeaderStart | MimeReaderState.HeaderIncomplete | MimeReaderState.HeaderComplete | MimeReaderState.EndOfHeaders | MimeReaderState.InlineStart))
     {
         throw new NotSupportedException(Strings.HeaderReaderCannotBeUsedInThisState);
     }
     if (checkPositionedOnHeader && MimeReader.StateIsOneOf(this.reader.ReaderState, MimeReaderState.PartStart | MimeReaderState.EndOfHeaders))
     {
         throw new InvalidOperationException(Strings.HeaderReaderIsNotPositionedOnAHeader);
     }
 }
Example #2
0
        public void WritePart(MimeReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            this.AssertOpen();
            if (!MimeReader.StateIsOneOf(reader.ReaderState, MimeReaderState.PartStart | MimeReaderState.InlineStart))
            {
                throw new InvalidOperationException(Strings.OperationNotValidInThisReaderState);
            }
            this.StartPart();
            MimeHeaderReader headerReader = reader.HeaderReader;

            while (headerReader.ReadNextHeader())
            {
                this.WriteHeader(headerReader);
            }
            this.WriteContent(reader);
            this.EndPart();
        }