/// <summary> /// Serializes the <paramref name="entity"/> as RFC 5322 text to <paramref name="writer"/> /// </summary> /// <param name="entity">The <see cref="MimeEntity"/> to serialize</param> /// <param name="entityWriter">The <see cref="MimeWriter"/> to which to serialize</param> public void Serialize(MimeEntity entity, MimeWriter entityWriter) { if (entity == null) { throw new ArgumentNullException("entity"); } if (entityWriter == null) { throw new ArgumentNullException("entityWriter"); } if (entity.HasHeaders) { entityWriter.Write(entity.Headers); entityWriter.WriteCRLF(); } if (entity.HasBody) { entityWriter.Write(entity.Body); if (entity is Message) { entityWriter.WriteCRLF(); } } }
/// <summary> /// Serialize fields to the given text writer /// </summary> /// <param name="writer"></param> public void Serialize(TextWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } using (MimeWriter mimeWriter = new MimeWriter(writer)) { mimeWriter.Write(m_fields); } }
/// <summary> /// Returns the header collection as a string /// The headers are formatted according to MIME rules /// </summary> /// <returns></returns> public override string ToString() { using (StringWriter stringWriter = new StringWriter()) { using (MimeWriter mimeWriter = new MimeWriter(stringWriter)) { mimeWriter.Write(this); } return(stringWriter.ToString()); } }