/// <summary>
 /// Resets the content stream and the <see cref="IsFull"/> property.
 /// </summary>
 private void ResetContentStream()
 {
     mContentStream?.Dispose();                 // returns buffers back to the pool
     mContentStream        = new MemoryBlockStream(ArrayPool <byte> .Shared);
     mRequestContentWriter = new Utf8JsonWriter(mContentStream, mJsonWriterOptions);
     IsFull = false;
 }
Example #2
0
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="SmtpClient"/> and
 /// optionally releases the managed resources.
 /// </summary>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources;
 /// <c>false</c> to release only the unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && !disposed)
     {
         if (queue != null)
         {
             queue.Dispose();
         }
         disposed = true;
         Disconnect();
     }
 }
Example #3
0
        async Task ConstructMimePartAsync(MimePart part, MimeEntityEndEventArgs args, CancellationToken cancellationToken)
        {
            long endOffset, beginOffset = GetOffset(inputIndex);
            var  beginLineNumber = lineNumber;
            ScanContentResult result;
            Stream            content;

            if (persistent)
            {
                using (var measured = new MeasuringStream()) {
                    result = await ScanContentAsync(measured, true, cancellationToken).ConfigureAwait(false);

                    endOffset = beginOffset + measured.Length;
                }

                content = new BoundStream(stream, beginOffset, endOffset, true);
            }
            else
            {
                content = new MemoryBlockStream();

                try {
                    result = await ScanContentAsync(content, true, cancellationToken).ConfigureAwait(false);

                    content.Seek(0, SeekOrigin.Begin);
                } catch {
                    content.Dispose();
                    throw;
                }

                endOffset = beginOffset + content.Length;
            }

            args.Lines = GetLineCount(beginLineNumber, beginOffset, endOffset);

            if (!result.IsEmpty)
            {
                part.Content = new MimeContent(content, part.ContentTransferEncoding)
                {
                    NewLineFormat = result.Format
                }
            }
            ;
            else
            {
                content.Dispose();
            }
        }
 public void TearDown()
 {
     blocks.Dispose();
     master.Dispose();
 }
Example #5
0
 public void Dispose()
 {
     blocks.Dispose();
     master.Dispose();
 }