Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SendMailAsyncResult.cs
Go to the documentation of this file.
2using System.IO;
5
6namespace System.Net.Mail;
7
8internal sealed class SendMailAsyncResult : System.Net.LazyAsyncResult
9{
10 private readonly SmtpConnection _connection;
11
12 private readonly MailAddress _from;
13
14 private readonly string _deliveryNotify;
15
16 private static readonly AsyncCallback s_sendMailFromCompleted = SendMailFromCompleted;
17
18 private static readonly AsyncCallback s_sendToCollectionCompleted = SendToCollectionCompleted;
19
20 private static readonly AsyncCallback s_sendDataCompleted = SendDataCompleted;
21
23
24 private Stream _stream;
25
27
28 private int _toIndex;
29
30 private readonly bool _allowUnicode;
31
32 internal SendMailAsyncResult(SmtpConnection connection, MailAddress from, MailAddressCollection toCollection, bool allowUnicode, string deliveryNotify, AsyncCallback callback, object state)
33 : base(null, state, callback)
34 {
36 _connection = connection;
37 _from = from;
40 }
41
42 internal void Send()
43 {
45 }
46
47 internal static MailWriter End(IAsyncResult result)
48 {
50 object obj = sendMailAsyncResult.InternalWaitForCompletion();
52 {
54 }
55 return new MailWriter(sendMailAsyncResult._stream, encodeForTransport: true);
56 }
57
67
68 private static void SendMailFromCompleted(IAsyncResult result)
69 {
70 if (!result.CompletedSynchronously)
71 {
73 try
74 {
75 MailCommand.EndSend(result);
76 sendMailAsyncResult.SendToCollection();
77 }
78 catch (Exception result2)
79 {
80 sendMailAsyncResult.InvokeCallback(result2);
81 }
82 }
83 }
84
101
102 private static void SendToCollectionCompleted(IAsyncResult result)
103 {
104 if (result.CompletedSynchronously)
105 {
106 return;
107 }
109 try
110 {
112 {
113 sendMailAsyncResult._failedRecipientExceptions.Add(new SmtpFailedRecipientException(sendMailAsyncResult._connection.Reader.StatusCode, sendMailAsyncResult._toCollection[sendMailAsyncResult._toIndex - 1].GetSmtpAddress(sendMailAsyncResult._allowUnicode), response));
114 if (sendMailAsyncResult._failedRecipientExceptions.Count == sendMailAsyncResult._toCollection.Count)
115 {
116 SmtpFailedRecipientException ex = ((sendMailAsyncResult._toCollection.Count == 1) ? sendMailAsyncResult._failedRecipientExceptions[0] : new SmtpFailedRecipientsException(sendMailAsyncResult._failedRecipientExceptions, allFailed: true));
117 ex.fatal = true;
118 sendMailAsyncResult.InvokeCallback(ex);
119 return;
120 }
121 }
122 sendMailAsyncResult.SendToCollection();
123 }
124 catch (Exception result2)
125 {
126 sendMailAsyncResult.InvokeCallback(result2);
127 }
128 }
129
151
152 private static void SendDataCompleted(IAsyncResult result)
153 {
154 if (result.CompletedSynchronously)
155 {
156 return;
157 }
159 try
160 {
161 DataCommand.EndSend(result);
162 sendMailAsyncResult._stream = sendMailAsyncResult._connection.GetClosableStream();
163 if (sendMailAsyncResult._failedRecipientExceptions.Count > 1)
164 {
165 sendMailAsyncResult.InvokeCallback(new SmtpFailedRecipientsException(sendMailAsyncResult._failedRecipientExceptions, sendMailAsyncResult._failedRecipientExceptions.Count == sendMailAsyncResult._toCollection.Count));
166 }
167 else if (sendMailAsyncResult._failedRecipientExceptions.Count == 1)
168 {
169 sendMailAsyncResult.InvokeCallback(sendMailAsyncResult._failedRecipientExceptions[0]);
170 }
171 else
172 {
173 sendMailAsyncResult.InvokeCallback();
174 }
175 }
176 catch (Exception result2)
177 {
178 sendMailAsyncResult.InvokeCallback(result2);
179 }
180 }
181
183 {
185 {
187 }
189 {
191 }
192 return null;
193 }
194}
void Add(TKey key, TValue value)
static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state)
Definition DataCommand.cs:5
static void EndSend(IAsyncResult result)
static IAsyncResult BeginSend(SmtpConnection conn, byte[] command, MailAddress from, bool allowUnicode, AsyncCallback callback, object state)
Definition MailCommand.cs:5
static void EndSend(IAsyncResult result)
static bool EndSend(IAsyncResult result, out string response)
static IAsyncResult BeginSend(SmtpConnection conn, string to, AsyncCallback callback, object state)
static readonly AsyncCallback s_sendToCollectionCompleted
SmtpFailedRecipientException GetFailedRecipientException()
static MailWriter End(IAsyncResult result)
static void SendToCollectionCompleted(IAsyncResult result)
static void SendDataCompleted(IAsyncResult result)
readonly MailAddressCollection _toCollection
SendMailAsyncResult(SmtpConnection connection, MailAddress from, MailAddressCollection toCollection, bool allowUnicode, string deliveryNotify, AsyncCallback callback, object state)
static readonly AsyncCallback s_sendMailFromCompleted
static void SendMailFromCompleted(IAsyncResult result)
static readonly AsyncCallback s_sendDataCompleted
readonly List< SmtpFailedRecipientException > _failedRecipientExceptions
static readonly byte[] Mail
SmtpReplyReaderFactory Reader