Merge pull request #3997 from lateralusX/jlorenss/win-api-family-support-safearray
[mono.git] / mcs / class / System / System.Net.Mail / SmtpFailedRecipientsException.cs
index 5eb20e924b6c80712c0284621a51f54bf8bb95e1..6f2e3af8e50d808092b2836f09c10893d703c199 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System.Collections;
 using System.Runtime.Serialization;
 
 namespace System.Net.Mail {
-       public class SmtpFailedRecipientsException : SmtpException
+       [Serializable]
+       public class SmtpFailedRecipientsException : SmtpFailedRecipientException, ISerializable
        {
                #region Fields
 
-               ArrayList exceptions = new ArrayList ();
-               ArrayList failedRecipients = new ArrayList ();
+               SmtpFailedRecipientException[] innerExceptions;
 
                #endregion // Fields
 
-               #region Properties
+               #region Constructors
+
+               public SmtpFailedRecipientsException ()
+               {
+               }
+
+               public SmtpFailedRecipientsException (string message) : base (message)
+               {
+               }
+
+               public SmtpFailedRecipientsException (string message, Exception innerException) : base (message, innerException)
+               {
+               }
 
-               public SmtpException[] Exceptions {
-                       get { return (SmtpException[]) exceptions.ToArray (typeof (SmtpException)); }
+               public SmtpFailedRecipientsException (string message, SmtpFailedRecipientException[] innerExceptions) : base (message)
+               {
+                       this.innerExceptions = innerExceptions;
+               }
+
+               protected SmtpFailedRecipientsException (SerializationInfo info, StreamingContext context)
+               : base(info, context)
+               {
+                       if (info == null)
+                               throw new ArgumentNullException ("info");
+                       innerExceptions = (SmtpFailedRecipientException []) info.GetValue ("innerExceptions", typeof (SmtpFailedRecipientException []));
                }
+               
+               #endregion
 
-               public string[] FailedRecipients {
-                       get { return (string[]) exceptions.ToArray (typeof (string)); }
+               #region Properties
+
+               public SmtpFailedRecipientException[] InnerExceptions {
+                       get { return innerExceptions; }
                }
 
                #endregion // Properties
 
                #region Methods
 
-               internal void AddFailedRecipient (SmtpException e, string recipient)
+               public override void GetObjectData (SerializationInfo info, StreamingContext context)
+               {
+                       if (info == null)
+                               throw new ArgumentNullException ("info");
+                       base.GetObjectData (info, context);
+                       info.AddValue ("innerExceptions", innerExceptions);
+               }
+
+               void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
                {
-                       exceptions.Add (e);
-                       failedRecipients.Add (recipient);
+                       GetObjectData (info, context);
                }
 
                #endregion // Methods
        }
 }
 
-#endif // NET_2_0