2010-06-16 Gonzalo Paniagua Javier <gonzalo@novell.com>
[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 #if NET_2_0
32
33 using System;
34 using System.Collections;
35 using System.Runtime.Serialization;
36
37 namespace System.Net.Mail {
38         [Serializable]
39         public class SmtpFailedRecipientException : SmtpException, ISerializable
40         {
41                 #region Fields
42
43                 string failedRecipient;
44
45                 #endregion // Fields
46
47                 #region Constructors
48
49                 public SmtpFailedRecipientException ()
50                 {
51                 }
52
53                 public SmtpFailedRecipientException (string message) : base (message)
54                 {
55                 }
56
57                 protected SmtpFailedRecipientException (SerializationInfo serializationInfo, StreamingContext streamingContext)
58                         : base (serializationInfo, streamingContext)
59                 {
60                         if (serializationInfo == null)
61                                 throw new ArgumentNullException ("serializationInfo");
62                         failedRecipient = serializationInfo.GetString ("failedRecipient");
63                 }
64
65                 public SmtpFailedRecipientException (SmtpStatusCode statusCode, string failedRecipient) : base (statusCode)
66                 {
67                         this.failedRecipient = failedRecipient;
68                 }
69
70                 public SmtpFailedRecipientException (string message, Exception innerException) : base (message, innerException)
71                 {
72                 }
73
74                 public SmtpFailedRecipientException (string message, string failedRecipient, Exception innerException) : base (message, innerException)
75                 {
76                         this.failedRecipient = failedRecipient;
77                 }
78
79                 public SmtpFailedRecipientException (SmtpStatusCode statusCode, string failedRecipient, string serverResponse) : base (statusCode, serverResponse)
80                 {
81                         this.failedRecipient = failedRecipient;
82                 }
83                 
84                 #endregion // Constructors
85                 
86                 #region Properties
87
88                 public string FailedRecipient {
89                         get { return failedRecipient; }
90                 }
91
92                 #endregion // Properties
93
94                 #region Methods
95
96                 public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
97                 {
98                         if (serializationInfo == null)
99                                 throw new ArgumentNullException ("serializationInfo");
100                         base.GetObjectData (serializationInfo, streamingContext);
101                         serializationInfo.AddValue ("failedRecipient", failedRecipient);
102                 }
103 #if !TARGET_JVM //remove private implementation
104                 void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
105                 {
106                         GetObjectData (serializationInfo, streamingContext);
107                 }
108 #endif
109
110                 #endregion // Methods
111         }
112 }
113
114 #endif // NET_2_0