Beispiel #1
0
 internal override IAsyncResult BeginSend(BaseWriter writer, AsyncCallback callback, bool allowUnicode, object state)
 {
     _allowUnicode = allowUnicode;
     base.PrepareHeaders(allowUnicode);
     writer.WriteHeaders(base.Headers, allowUnicode);
     var result = new MimeBasePart.MimePartAsyncResult(this, state, callback);
     var context = new MimePartContext(writer, result, Parts.GetEnumerator());
     var result2 = writer.BeginGetContentStream(new AsyncCallback(ContentStreamCallback), context);
     if (result2.CompletedSynchronously)
         ContentStreamCallbackHandler(result2);
     return result;
 }
 internal override IAsyncResult BeginSend(BaseWriter writer, AsyncCallback callback, object state)
 {
     writer.WriteHeaders(base.Headers);
     MimeBasePart.MimePartAsyncResult result = new MimeBasePart.MimePartAsyncResult(this, state, callback);
     MimePartContext context = new MimePartContext(writer, result, this.Parts.GetEnumerator());
     IAsyncResult result2 = writer.BeginGetContentStream(new AsyncCallback(this.ContentStreamCallback), context);
     if (result2.CompletedSynchronously)
     {
         this.ContentStreamCallbackHandler(result2);
     }
     return result;
 }
Beispiel #3
0
        internal override IAsyncResult BeginSend(BaseWriter writer, AsyncCallback callback, object state)
        {
            writer.WriteHeaders(base.Headers);
            MimeBasePart.MimePartAsyncResult result = new MimeBasePart.MimePartAsyncResult(this, state, callback);
            MimePartContext context = new MimePartContext(writer, result, this.Parts.GetEnumerator());
            IAsyncResult    result2 = writer.BeginGetContentStream(new AsyncCallback(this.ContentStreamCallback), context);

            if (result2.CompletedSynchronously)
            {
                this.ContentStreamCallbackHandler(result2);
            }
            return(result);
        }
 internal virtual IAsyncResult BeginSend(BaseWriter writer, bool sendEnvelope, AsyncCallback callback, object state)
 {
     this.PrepareHeaders(sendEnvelope);
     writer.WriteHeaders(this.Headers);
     if (this.Content != null)
     {
         return this.Content.BeginSend(writer, callback, state);
     }
     LazyAsyncResult result = new LazyAsyncResult(this, state, callback);
     IAsyncResult result2 = writer.BeginGetContentStream(new AsyncCallback(this.EmptySendCallback), new EmptySendContext(writer, result));
     if (result2.CompletedSynchronously)
     {
         writer.EndGetContentStream(result2).Close();
     }
     return result;
 }
Beispiel #5
0
        internal override IAsyncResult BeginSend(BaseWriter writer, AsyncCallback?callback, bool allowUnicode,
                                                 object?state)
        {
            _allowUnicode = allowUnicode;
            PrepareHeaders(allowUnicode);
            writer.WriteHeaders(Headers, allowUnicode);
            MimePartAsyncResult result        = new MimePartAsyncResult(this, state, callback);
            MimePartContext     context       = new MimePartContext(writer, result, Parts.GetEnumerator());
            IAsyncResult        contentResult = writer.BeginGetContentStream(new AsyncCallback(ContentStreamCallback), context);

            if (contentResult.CompletedSynchronously)
            {
                ContentStreamCallbackHandler(contentResult);
            }
            return(result);
        }
Beispiel #6
0
        internal override IAsyncResult BeginSend(BaseWriter writer, AsyncCallback callback, bool allowUnicode, object state)
        {
            PrepareHeaders(allowUnicode);
            writer.WriteHeaders(Headers, allowUnicode);
            MimePartAsyncResult result  = new MimePartAsyncResult(this, state, callback);
            MimePartContext     context = new MimePartContext(writer, result);

            ResetStream();
            _streamUsedOnce = true;
            IAsyncResult contentResult = writer.BeginGetContentStream(new AsyncCallback(ContentStreamCallback), context);

            if (contentResult.CompletedSynchronously)
            {
                ContentStreamCallbackHandler(contentResult);
            }
            return(result);
        }
Beispiel #7
0
        internal virtual IAsyncResult BeginSend(BaseWriter writer, bool sendEnvelope, bool allowUnicode,
            AsyncCallback callback, object state)
        {
            PrepareHeaders(sendEnvelope, allowUnicode);
            writer.WriteHeaders(Headers, allowUnicode);

            if (Content != null)
            {
                return Content.BeginSend(writer, callback, allowUnicode, state);
            }
            else
            {
                LazyAsyncResult result = new LazyAsyncResult(this, state, callback);
                IAsyncResult newResult = writer.BeginGetContentStream(EmptySendCallback, new EmptySendContext(writer, result));
                if (newResult.CompletedSynchronously)
                {
                    writer.EndGetContentStream(newResult).Close();
                }
                return result;
            }
        }
 internal override IAsyncResult BeginSend(BaseWriter writer, AsyncCallback callback, bool allowUnicode, 
     object state)
 {
     this.allowUnicode = allowUnicode;
     PrepareHeaders(allowUnicode);
     writer.WriteHeaders(Headers, allowUnicode);
     MimePartAsyncResult result = new MimePartAsyncResult(this, state, callback);
     MimePartContext context = new MimePartContext(writer, result, Parts.GetEnumerator());
     IAsyncResult contentResult = writer.BeginGetContentStream(new AsyncCallback(ContentStreamCallback), context);
     if (contentResult.CompletedSynchronously) {
        ContentStreamCallbackHandler(contentResult);
     }
     return result;
 }