2009-03-03 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / System / System.Net / WebProxy.cs
index 4a31deea5a91cb22b0207f5766e46be910a037f0..9232dbf5fb04e66a6f73c2177e44277a32b60278 100644 (file)
@@ -142,6 +142,9 @@ namespace System.Net
 #endif
 
                // Methods
+#if NET_2_0
+               [Obsolete ("This method has been deprecated", false)]
+#endif
                [MonoTODO("Can we get this info under windows from the system?")]
                public static WebProxy GetDefaultProxy ()
                {
@@ -168,7 +171,10 @@ namespace System.Net
                                throw new ArgumentNullException ("host");
 #endif
 
-                       if (bypassOnLocal && host.IsLoopback)
+                       if (host.IsLoopback && bypassOnLocal)
+                               return true;
+
+                       if (address == null)
                                return true;
 
                        string server = host.Host;
@@ -182,14 +188,12 @@ namespace System.Net
                                if (String.Compare (server, "loopback", true, CultureInfo.InvariantCulture) == 0)
                                        return true;
 
-                               try {
-                                       IPAddress addr = IPAddress.Parse (server);
-                                       if (IPAddress.IsLoopback (addr))
-                                               return true;
-                               } catch {}
+                               IPAddress addr = null;
+                               if (IPAddress.TryParse (server, out addr) && IPAddress.IsLoopback (addr))
+                                       return true;
                        }
 
-                       if (bypassList == null)
+                       if (bypassList == null || bypassList.Count == 0)
                                return false;
 
                        try {
@@ -219,8 +223,10 @@ namespace System.Net
                        }
                }
 
-               void ISerializable.GetObjectData (SerializationInfo serializationInfo,
-                                                 StreamingContext streamingContext)
+#if NET_2_0
+               protected virtual 
+#endif
+               void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
                {
                        serializationInfo.AddValue ("_BypassOnLocal", bypassOnLocal);
                        serializationInfo.AddValue ("_ProxyAddress", address);
@@ -230,6 +236,12 @@ namespace System.Net
 #endif
                }
 
+               void ISerializable.GetObjectData (SerializationInfo serializationInfo,
+                                                 StreamingContext streamingContext)
+               {
+                       GetObjectData (serializationInfo, streamingContext);
+               }
+
                // Private Methods
                // this compiles the regular expressions, and will throw
                // an exception when an invalid one is found.