Ejemplo n.º 1
0
 internal static void CalculateBodySize(MimePartInfo partInfo, MimePart part)
 {
     if (partInfo.IsBodySizeComputed)
     {
         return;
     }
     using (Stream stream = new MimeStreamWriter.MimeBodySizeCounter(null, partInfo))
     {
         using (Stream rawContentReadStream = part.GetRawContentReadStream())
         {
             Util.StreamHandler.CopyStreamData(rawContentReadStream, stream);
         }
     }
 }
Ejemplo n.º 2
0
        internal Stream GetContentStream(bool writeToSkeleton)
        {
            this.StartWriting();
            this.Flush();
            Stream stream = null;
            bool   flag   = false;

            try
            {
                if (this.mimeWriter != null)
                {
                    stream = this.mimeWriter.GetRawContentWriteStream();
                }
                if (writeToSkeleton && this.mimeSkeletonWriter != null)
                {
                    Stream rawContentWriteStream = this.mimeSkeletonWriter.GetRawContentWriteStream();
                    stream = ((stream == null) ? rawContentWriteStream : new MimeStreamWriter.SplitterWriteStream(stream, rawContentWriteStream));
                }
                if (this.currentPart != null && (this.flags & MimeStreamWriter.Flags.ProduceMimeStructure) == MimeStreamWriter.Flags.ProduceMimeStructure && !this.currentPart.IsBodySizeComputed)
                {
                    stream = new MimeStreamWriter.MimeBodySizeCounter(stream, this.currentPart);
                }
                if (stream == null)
                {
                    stream = new MimeStreamWriter.MimeTextStream(null);
                }
                flag = true;
            }
            finally
            {
                if (!flag && stream != null)
                {
                    stream.Dispose();
                }
            }
            return(stream);
        }