2 using System.Collections;
3 using System.Diagnostics.CodeAnalysis;
4 using System.Runtime.Serialization;
5 using System.Security.Permissions;
7 namespace System.Net.Mail
10 /// Summary description for SmtpFailedRecipientsException.
13 public class SmtpFailedRecipientsException : SmtpFailedRecipientException, ISerializable
15 SmtpFailedRecipientException[] innerExceptions;
19 public SmtpFailedRecipientsException()
21 innerExceptions = new SmtpFailedRecipientException[0];
24 public SmtpFailedRecipientsException(string message) : base(message)
26 innerExceptions = new SmtpFailedRecipientException[0];
29 public SmtpFailedRecipientsException(string message, Exception innerException) : base(message, innerException)
31 SmtpFailedRecipientException smtpException = innerException as SmtpFailedRecipientException;
32 this.innerExceptions = smtpException == null ? new SmtpFailedRecipientException[0] : new SmtpFailedRecipientException[] { smtpException };
35 protected SmtpFailedRecipientsException(SerializationInfo info, StreamingContext context) : base(info, context)
37 innerExceptions = (SmtpFailedRecipientException[]) info.GetValue("innerExceptions", typeof(SmtpFailedRecipientException[]));
41 public SmtpFailedRecipientsException(string message, SmtpFailedRecipientException[] innerExceptions) :
42 base(message, innerExceptions != null && innerExceptions.Length > 0 ? innerExceptions[0].FailedRecipient : null,
43 innerExceptions != null && innerExceptions.Length > 0 ? innerExceptions[0] : null)
45 if (innerExceptions == null)
47 throw new ArgumentNullException("innerExceptions");
50 this.innerExceptions = innerExceptions == null ? new SmtpFailedRecipientException[0] : innerExceptions;
53 internal SmtpFailedRecipientsException(ArrayList innerExceptions, bool allFailed) :
54 base(allFailed ? SR.GetString(SR.SmtpAllRecipientsFailed) : SR.GetString(SR.SmtpRecipientFailed),
55 innerExceptions != null && innerExceptions.Count > 0 ? ((SmtpFailedRecipientException) innerExceptions[0]).FailedRecipient : null,
56 innerExceptions != null && innerExceptions.Count > 0 ? (SmtpFailedRecipientException) innerExceptions[0] : null)
58 if (innerExceptions == null)
60 throw new ArgumentNullException("innerExceptions");
63 this.innerExceptions = new SmtpFailedRecipientException[innerExceptions.Count];
65 foreach(SmtpFailedRecipientException e in innerExceptions) {
66 this.innerExceptions[i++]=e;
70 public SmtpFailedRecipientException[] InnerExceptions
74 return innerExceptions;
85 [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.dll is still using pre-v4 security model and needs this demand")]
86 [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)]
87 void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
89 GetObjectData(serializationInfo, streamingContext);
93 // FxCop: provide some way for derived classes to access GetObjectData even if the derived class
94 // explicitly re-inherits ISerializable.
96 [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)]
97 public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
99 base.GetObjectData(serializationInfo, streamingContext);
100 serializationInfo.AddValue("innerExceptions", innerExceptions, typeof(SmtpFailedRecipientException[]));