Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ReadLinesCommand.cs
Go to the documentation of this file.
3
4namespace System.Net.Mail;
5
6internal static class ReadLinesCommand
7{
8 private static readonly AsyncCallback s_onReadLines = OnReadLines;
9
10 private static readonly AsyncCallback s_onWrite = OnWrite;
11
12 internal static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state)
13 {
14 MultiAsyncResult multiAsyncResult = new MultiAsyncResult(conn, callback, state);
15 multiAsyncResult.Enter();
16 IAsyncResult asyncResult = conn.BeginFlush(s_onWrite, multiAsyncResult);
17 if (asyncResult.CompletedSynchronously)
18 {
20 multiAsyncResult.Leave();
21 }
22 SmtpReplyReader nextReplyReader = conn.Reader.GetNextReplyReader();
23 multiAsyncResult.Enter();
24 IAsyncResult asyncResult2 = nextReplyReader.BeginReadLines(s_onReadLines, multiAsyncResult);
25 if (asyncResult2.CompletedSynchronously)
26 {
27 LineInfo[] result = conn.Reader.CurrentReader.EndReadLines(asyncResult2);
28 if (!(multiAsyncResult.Result is Exception))
29 {
30 multiAsyncResult.Result = result;
31 }
32 multiAsyncResult.Leave();
33 }
34 multiAsyncResult.CompleteSequence();
35 return multiAsyncResult;
36 }
37
38 internal static LineInfo[] EndSend(IAsyncResult result)
39 {
40 object obj = MultiAsyncResult.End(result);
41 if (obj is Exception source)
42 {
44 }
45 return (LineInfo[])obj;
46 }
47
48 private static void OnReadLines(IAsyncResult result)
49 {
50 if (result.CompletedSynchronously)
51 {
52 return;
53 }
54 MultiAsyncResult multiAsyncResult = (MultiAsyncResult)result.AsyncState;
55 try
56 {
57 SmtpConnection smtpConnection = (SmtpConnection)multiAsyncResult.Context;
58 LineInfo[] result2 = smtpConnection.Reader.CurrentReader.EndReadLines(result);
59 if (!(multiAsyncResult.Result is Exception))
60 {
61 multiAsyncResult.Result = result2;
62 }
63 multiAsyncResult.Leave();
64 }
65 catch (Exception result3)
66 {
67 multiAsyncResult.Leave(result3);
68 }
69 }
70
71 private static void OnWrite(IAsyncResult result)
72 {
73 if (!result.CompletedSynchronously)
74 {
75 MultiAsyncResult multiAsyncResult = (MultiAsyncResult)result.AsyncState;
76 try
77 {
78 SmtpConnection smtpConnection = (SmtpConnection)multiAsyncResult.Context;
79 smtpConnection.EndFlush(result);
80 multiAsyncResult.Leave();
81 }
82 catch (Exception result2)
83 {
84 multiAsyncResult.Leave(result2);
85 }
86 }
87 }
88
89 internal static LineInfo[] Send(SmtpConnection conn)
90 {
91 conn.Flush();
92 return conn.Reader.GetNextReplyReader().ReadLines();
93 }
94}
static LineInfo[] EndSend(IAsyncResult result)
static void OnWrite(IAsyncResult result)
static readonly AsyncCallback s_onReadLines
static readonly AsyncCallback s_onWrite
static void OnReadLines(IAsyncResult result)
static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state)
static LineInfo[] Send(SmtpConnection conn)
SmtpReplyReaderFactory Reader
void EndFlush(IAsyncResult result)
IAsyncResult BeginFlush(AsyncCallback callback, object state)
IAsyncResult BeginReadLines(AsyncCallback callback, object state)
LineInfo[] EndReadLines(IAsyncResult result)
static object End(IAsyncResult result)