internal IAsyncResult BeginClose(AsyncCallback callback, object state) { var multiResult = new MultiAsyncResult(this, callback, state); Close(multiResult); multiResult.CompleteSequence(); return multiResult; }
internal static object End(IAsyncResult result) { MultiAsyncResult result2 = (MultiAsyncResult)result; result2.InternalWaitForCompletion(); return(result2.Result); }
internal static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state) { MultiAsyncResult multiResult = new MultiAsyncResult(conn, callback, state); multiResult.Enter(); IAsyncResult writeResult = conn.BeginFlush(s_onWrite, multiResult); if (writeResult.CompletedSynchronously) { conn.EndFlush(writeResult); multiResult.Leave(); } SmtpReplyReader reader = conn.Reader.GetNextReplyReader(); multiResult.Enter(); //this actually does a read on the stream. IAsyncResult result = reader.BeginReadLine(s_onReadLine, multiResult); if (result.CompletedSynchronously) { LineInfo info = reader.EndReadLine(result); if (!(multiResult.Result is Exception)) multiResult.Result = info; multiResult.Leave(); } multiResult.CompleteSequence(); return multiResult; }
internal static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state) { MultiAsyncResult result = new MultiAsyncResult(conn, callback, state); result.Enter(); IAsyncResult result2 = conn.BeginFlush(onWrite, result); if (result2.CompletedSynchronously) { conn.EndFlush(result2); result.Leave(); } SmtpReplyReader nextReplyReader = conn.Reader.GetNextReplyReader(); result.Enter(); IAsyncResult result3 = nextReplyReader.BeginReadLines(onReadLines, result); if (result3.CompletedSynchronously) { LineInfo[] infoArray = conn.Reader.CurrentReader.EndReadLines(result3); if (!(result.Result is Exception)) { result.Result = infoArray; } result.Leave(); } result.CompleteSequence(); return result; }
internal IAsyncResult BeginClose(AsyncCallback callback, object state) { MultiAsyncResult multiResult = new MultiAsyncResult(this, callback, state); this.Close(multiResult); multiResult.CompleteSequence(); return(multiResult); }
private void Close(MultiAsyncResult multiResult) { _bufferBuilder.Append(s_crlf); _bufferBuilder.Append(s_DASHDASH); _bufferBuilder.Append(_boundaryBytes); _bufferBuilder.Append(s_DASHDASH); _bufferBuilder.Append(s_crlf); Flush(multiResult); }
void Close(MultiAsyncResult multiResult) { this.bufferBuilder.Append(CRLF); this.bufferBuilder.Append(DASHDASH); this.bufferBuilder.Append(this.boundaryBytes); this.bufferBuilder.Append(DASHDASH); this.bufferBuilder.Append(CRLF); Flush(multiResult); }
internal IAsyncResult BeginGetContentStream(AsyncCallback callback, object state) { var multiResult = new MultiAsyncResult(this, callback, state); var contentStream = GetContentStream(multiResult); if (!(multiResult.Result is Exception)) multiResult.Result = contentStream; multiResult.CompleteSequence(); return multiResult; }
void Close(MultiAsyncResult multiResult) { this.bufferBuilder.Append(CRLF); this.bufferBuilder.Append(DASHDASH); this.bufferBuilder.Append(this.boundaryBytes); this.bufferBuilder.Append(DASHDASH); this.bufferBuilder.Append(CRLF); Flush(multiResult); }
private void Close(MultiAsyncResult multiResult) { base._bufferBuilder.Append(BaseWriter.CRLF); base._bufferBuilder.Append(DASHDASH); base._bufferBuilder.Append(_boundaryBytes); base._bufferBuilder.Append(DASHDASH); base._bufferBuilder.Append(BaseWriter.CRLF); base.Flush(multiResult); }
private void Close(MultiAsyncResult multiResult) { _bufferBuilder.Append(s_crlf); _bufferBuilder.Append(s_DASHDASH); _bufferBuilder.Append(_boundaryBytes); _bufferBuilder.Append(s_DASHDASH); _bufferBuilder.Append(s_crlf); Flush(multiResult); }
internal Stream EndGetContentStream(IAsyncResult result) { object o = MultiAsyncResult.End(result); if (o is Exception) { throw (Exception)o; } return((Stream)o); }
internal Stream EndGetContentStream(IAsyncResult result) { object o = MultiAsyncResult.End(result); if (o is Exception e) { ExceptionDispatchInfo.Throw(e); } return((Stream)o); }
internal override Stream EndGetContentStream(IAsyncResult result) { object obj2 = MultiAsyncResult.End(result); if (obj2 is Exception) { throw ((Exception)obj2); } return((Stream)obj2); }
internal IAsyncResult BeginGetContentStream(ContentTransferEncoding contentTransferEncoding, AsyncCallback callback, object state) { MultiAsyncResult multiResult = new MultiAsyncResult(this, callback, state); Stream contentStream = this.GetContentStream(contentTransferEncoding, multiResult); if (!(multiResult.Result is Exception)) { multiResult.Result = contentStream; } multiResult.CompleteSequence(); return multiResult; }
internal IAsyncResult BeginGetContentStream(ContentTransferEncoding contentTransferEncoding, AsyncCallback callback, object state) { MultiAsyncResult multiResult = new MultiAsyncResult(this, callback, state); Stream contentStream = this.GetContentStream(contentTransferEncoding, multiResult); if (!(multiResult.Result is Exception)) { multiResult.Result = contentStream; } multiResult.CompleteSequence(); return(multiResult); }
private Stream GetContentStream(MultiAsyncResult multiResult) { if (_isInContent) throw new InvalidOperationException(SR.GetString("MailWriterIsInContent")); _isInContent = true; CheckBoundary(); _bufferBuilder.Append(CRLF); Flush(multiResult); var stream = new EightBitStream(_stream, _shouldEncodeLeadingDots); var stream2 = new ClosableStream(stream, _onCloseHandler); _contentStream = stream2; return stream2; }
internal IAsyncResult BeginGetContentStream(AsyncCallback callback, object state) { MultiAsyncResult multiResult = new MultiAsyncResult(this, callback, state); Stream s = GetContentStream(multiResult); if (!(multiResult.Result is Exception)) { multiResult.Result = s; } multiResult.CompleteSequence(); return(multiResult); }
private static void OnWrite(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult asyncState = (MultiAsyncResult)result.AsyncState; MimeWriter context = (MimeWriter)asyncState.Context; try { context.stream.EndWrite(result); asyncState.Leave(); } catch (Exception exception) { asyncState.Leave(exception); } } }
protected static void OnWrite(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult multiResult = (MultiAsyncResult)result.AsyncState; BaseWriter thisPtr = (BaseWriter)multiResult.Context; try { thisPtr._stream.EndWrite(result); multiResult.Leave(); } catch (Exception e) { multiResult.Leave(e); } } }
private Stream GetContentStream(MultiAsyncResult multiResult) { if (_isInContent) { throw new InvalidOperationException(SR.MailWriterIsInContent); } _isInContent = true; CheckBoundary(); _bufferBuilder.Append(s_crlf); Flush(multiResult); ClosableStream cs = new ClosableStream(new EightBitStream(_stream, _shouldEncodeLeadingDots), _onCloseHandler); _contentStream = cs; return(cs); }
protected void Flush(MultiAsyncResult multiResult) { if (_bufferBuilder.Length > 0) { if (multiResult != null) { multiResult.Enter(); var asyncResult = _stream.BeginWrite(_bufferBuilder.GetBuffer(), 0, _bufferBuilder.Length, _onWrite, multiResult); if (asyncResult.CompletedSynchronously) { _stream.EndWrite(asyncResult); multiResult.Leave(); } } else _stream.Write(_bufferBuilder.GetBuffer(), 0, _bufferBuilder.Length); _bufferBuilder.Reset(); } }
private Stream GetContentStream(MultiAsyncResult multiResult) { if (this.isInContent) { throw new InvalidOperationException(SR.GetString(SR.MailWriterIsInContent)); } this.isInContent = true; CheckBoundary(); this.bufferBuilder.Append(CRLF); Flush(multiResult); Stream tempStream = new EightBitStream(this.stream, shouldEncodeLeadingDots); ClosableStream cs = new ClosableStream(tempStream, this.onCloseHandler); this.contentStream = cs; return(cs); }
private void Flush(MultiAsyncResult multiResult) { if (this.bufferBuilder.Length > 0) { if (multiResult != null) { multiResult.Enter(); IAsyncResult asyncResult = this.stream.BeginWrite(this.bufferBuilder.GetBuffer(), 0, this.bufferBuilder.Length, onWrite, multiResult); if (asyncResult.CompletedSynchronously) { this.stream.EndWrite(asyncResult); multiResult.Leave(); } } else { this.stream.Write(this.bufferBuilder.GetBuffer(), 0, this.bufferBuilder.Length); } this.bufferBuilder.Reset(); } }
private void Flush(MultiAsyncResult multiResult) { if (this.bufferBuilder.Length > 0) { if (multiResult != null) { multiResult.Enter(); IAsyncResult asyncResult = this.stream.BeginWrite(this.bufferBuilder.GetBuffer(), 0, this.bufferBuilder.Length, onWrite, multiResult); if (asyncResult.CompletedSynchronously) { this.stream.EndWrite(asyncResult); multiResult.Leave(); } } else { this.stream.Write(this.bufferBuilder.GetBuffer(), 0, this.bufferBuilder.Length); } this.bufferBuilder.Reset(); } }
protected void Flush(MultiAsyncResult multiResult) { if (_bufferBuilder.Length > 0) { if (multiResult != null) { multiResult.Enter(); IAsyncResult result = _stream.BeginWrite(_bufferBuilder.GetBuffer(), 0, _bufferBuilder.Length, s_onWrite, multiResult); if (result.CompletedSynchronously) { _stream.EndWrite(result); multiResult.Leave(); } } else { _stream.Write(_bufferBuilder.GetBuffer(), 0, _bufferBuilder.Length); } _bufferBuilder.Reset(); } }
private Stream GetContentStream(ContentTransferEncoding contentTransferEncoding, MultiAsyncResult multiResult) { if (this.isInContent) { throw new InvalidOperationException(SR.GetString("MailWriterIsInContent")); } this.isInContent = true; this.bufferBuilder.Append(CRLF); this.Flush(multiResult); Stream stream = this.stream; if (contentTransferEncoding == ContentTransferEncoding.SevenBit) { stream = new SevenBitStream(stream); } else if (contentTransferEncoding == ContentTransferEncoding.QuotedPrintable) { stream = new QuotedPrintableStream(stream, this.lineLength); } else if (contentTransferEncoding == ContentTransferEncoding.Base64) { stream = new Base64Stream(stream, this.lineLength); } ClosableStream stream2 = new ClosableStream(stream, this.onCloseHandler); this.contentStream = stream2; return stream2; }
internal void EndClose(IAsyncResult result) { MultiAsyncResult.End(result); this.stream.Close(); }
private Stream GetContentStream(MultiAsyncResult multiResult) { if (_isInContent) { throw new InvalidOperationException(SR.MailWriterIsInContent); } _isInContent = true; CheckBoundary(); _bufferBuilder.Append(s_crlf); Flush(multiResult); ClosableStream cs = new ClosableStream(new EightBitStream(_stream, _shouldEncodeLeadingDots), _onCloseHandler); _contentStream = cs; return cs; }
private Stream GetContentStream(ContentTransferEncoding contentTransferEncoding, MultiAsyncResult multiResult) { this.CheckBoundary(); this.bufferBuilder.Append(CRLF); this.Flush(multiResult); Stream stream = this.stream; if (contentTransferEncoding == ContentTransferEncoding.SevenBit) { stream = new SevenBitStream(stream); } else if (contentTransferEncoding == ContentTransferEncoding.QuotedPrintable) { stream = new QuotedPrintableStream(stream, this.lineLength); } else if (contentTransferEncoding == ContentTransferEncoding.Base64) { stream = new Base64Stream(stream, this.lineLength); } ClosableStream stream2 = new ClosableStream(stream, this.onCloseHandler); this.contentStream = stream2; return stream2; }
private Stream GetContentStream(MultiAsyncResult multiResult) { if (this.isInContent) throw new InvalidOperationException(SR.GetString(SR.MailWriterIsInContent)); this.isInContent = true; CheckBoundary(); this.bufferBuilder.Append(CRLF); Flush(multiResult); Stream tempStream = new EightBitStream(this.stream, shouldEncodeLeadingDots); ClosableStream cs = new ClosableStream(tempStream, this.onCloseHandler); this.contentStream = cs; return cs; }
private Stream GetContentStream(ContentTransferEncoding contentTransferEncoding, MultiAsyncResult multiResult) { this.CheckBoundary(); this.bufferBuilder.Append(CRLF); this.Flush(multiResult); Stream stream = this.stream; if (contentTransferEncoding == ContentTransferEncoding.SevenBit) { stream = new SevenBitStream(stream); } else if (contentTransferEncoding == ContentTransferEncoding.QuotedPrintable) { stream = new QuotedPrintableStream(stream, this.lineLength); } else if (contentTransferEncoding == ContentTransferEncoding.Base64) { stream = new Base64Stream(stream, this.lineLength); } ClosableStream stream2 = new ClosableStream(stream, this.onCloseHandler); this.contentStream = stream2; return(stream2); }
internal static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state) { MultiAsyncResult multiResult = new MultiAsyncResult(conn, callback, state); multiResult.Enter(); IAsyncResult writeResult = conn.BeginFlush(s_onWrite, multiResult); if (writeResult.CompletedSynchronously) { conn.EndFlush(writeResult); multiResult.Leave(); } SmtpReplyReader reader = conn.Reader.GetNextReplyReader(); multiResult.Enter(); IAsyncResult readLinesResult = reader.BeginReadLines(s_onReadLines, multiResult); if (readLinesResult.CompletedSynchronously) { LineInfo[] lines = conn.Reader.CurrentReader.EndReadLines(readLinesResult); if (!(multiResult.Result is Exception)) multiResult.Result = lines; multiResult.Leave(); } multiResult.CompleteSequence(); return multiResult; }