2007-10-16 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 16 Oct 2007 14:43:21 +0000 (14:43 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 16 Oct 2007 14:43:21 +0000 (14:43 -0000)
* SmtpClient.cs : do state check on other setters than set_Timeout().

svn path=/trunk/mcs/; revision=87591

mcs/class/System/System.Net.Mail/ChangeLog
mcs/class/System/System.Net.Mail/SmtpClient.cs

index 817a0bf5f48d4ade6e38262ab09683fb371fcdb2..65a108d7d3529d43f7243e406103eca700e68752 100644 (file)
@@ -1,3 +1,7 @@
+2007-10-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SmtpClient.cs : do state check on other setters than set_Timeout().
+
 2007-10-16  Atsushi Enomoto  <atsushi@ximian.com>
 
        * MailMessage.cs : Some entire refactory on BodyEncoding and
index 1167e28eaa4718e13628cdf3976691623541b7f7..7a4cca103284b2158bc98d6c4cfaa451b0214a68 100644 (file)
@@ -141,28 +141,37 @@ namespace System.Net.Mail {
 
                public ICredentialsByHost Credentials {
                        get { return credentials; }
-                       set { credentials = value; }
+                       set {
+                               CheckState ();
+                               credentials = value;
+                       }
                }
 
                public SmtpDeliveryMethod DeliveryMethod {
                        get { return deliveryMethod; }
-                       set { deliveryMethod = value; }
+                       set {
+                               CheckState ();
+                               deliveryMethod = value;
+                       }
                }
 
                public bool EnableSsl {
                        // FIXME: So... is this supposed to enable SSL port functionality? or STARTTLS? Or both?
                        get { return enableSsl; }
-                       set { enableSsl = value; }
+                       set {
+                               CheckState ();
+                               enableSsl = value;
+                       }
                }
 
                public string Host {
                        get { return host; }
-                       // FIXME: Check to make sure an email is not being sent.
                        set {
                                if (value == null)
                                        throw new ArgumentNullException ();
                                if (value.Length == 0)
                                        throw new ArgumentException ();
+                               CheckState ();
                                host = value;
                        }
                }
@@ -174,10 +183,10 @@ namespace System.Net.Mail {
 
                public int Port {
                        get { return port; }
-                       // FIXME: Check to make sure an email is not being sent.
                        set { 
                                if (value <= 0 || value > 65535)
                                        throw new ArgumentOutOfRangeException ();
+                               CheckState ();
                                port = value;
                        }
                }
@@ -191,8 +200,7 @@ namespace System.Net.Mail {
                        set { 
                                if (value < 0)
                                        throw new ArgumentOutOfRangeException ();
-                               if (messageInProcess != null)
-                                       throw new InvalidOperationException ("Cannot set Timeout while Sending a message");
+                               CheckState ();
                                timeout = value; 
                        }
                }
@@ -203,6 +211,7 @@ namespace System.Net.Mail {
                        set {
                                if (value)
                                        throw new NotImplementedException ("Default credentials are not supported");
+                               CheckState ();
                        }
                }
 
@@ -216,6 +225,12 @@ namespace System.Net.Mail {
 
                #region Methods
 
+               private void CheckState ()
+               {
+                       if (messageInProcess != null)
+                               throw new InvalidOperationException ("Cannot set Timeout while Sending a message");
+               }
+
                private string EncodeSubjectRFC2047 (MailMessage message)
                {
                        if (message.SubjectEncoding == null || Encoding.ASCII.Equals (message.SubjectEncoding))