Merge pull request #347 from JamesB7/master
[mono.git] / mcs / class / System / System.Net.Mail / SmtpFailedRecipientException.cs
1 //
2 // System.Net.Mail.SmtpFailedRecipientException.cs
3 //
4 // Author:
5 //      John Luke (john.luke@gmail.com)
6 //
7 // Copyright (C) John Luke, 2005
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Collections;
33 using System.Runtime.Serialization;
34
35 namespace System.Net.Mail {
36         [Serializable]
37         public class SmtpFailedRecipientException : SmtpException, ISerializable
38         {
39                 #region Fields
40
41                 string failedRecipient;
42
43                 #endregion // Fields
44
45                 #region Constructors
46
47                 public SmtpFailedRecipientException ()
48                 {
49                 }
50
51                 public SmtpFailedRecipientException (string message) : base (message)
52                 {
53                 }
54
55                 protected SmtpFailedRecipientException (SerializationInfo serializationInfo, StreamingContext streamingContext)
56                         : base (serializationInfo, streamingContext)
57                 {
58                         if (serializationInfo == null)
59                                 throw new ArgumentNullException ("serializationInfo");
60                         failedRecipient = serializationInfo.GetString ("failedRecipient");
61                 }
62
63                 public SmtpFailedRecipientException (SmtpStatusCode statusCode, string failedRecipient) : base (statusCode)
64                 {
65                         this.failedRecipient = failedRecipient;
66                 }
67
68                 public SmtpFailedRecipientException (string message, Exception innerException) : base (message, innerException)
69                 {
70                 }
71
72                 public SmtpFailedRecipientException (string message, string failedRecipient, Exception innerException) : base (message, innerException)
73                 {
74                         this.failedRecipient = failedRecipient;
75                 }
76
77                 public SmtpFailedRecipientException (SmtpStatusCode statusCode, string failedRecipient, string serverResponse) : base (statusCode, serverResponse)
78                 {
79                         this.failedRecipient = failedRecipient;
80                 }
81                 
82                 #endregion // Constructors
83                 
84                 #region Properties
85
86                 public string FailedRecipient {
87                         get { return failedRecipient; }
88                 }
89
90                 #endregion // Properties
91
92                 #region Methods
93
94                 public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
95                 {
96                         if (serializationInfo == null)
97                                 throw new ArgumentNullException ("serializationInfo");
98                         base.GetObjectData (serializationInfo, streamingContext);
99                         serializationInfo.AddValue ("failedRecipient", failedRecipient);
100                 }
101 #if !TARGET_JVM //remove private implementation
102                 void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
103                 {
104                         GetObjectData (serializationInfo, streamingContext);
105                 }
106 #endif
107
108                 #endregion // Methods
109         }
110 }
111