[runtime] Replace pedump boehm dependency with sgen dependency
[mono.git] / mcs / class / System / System.Net / WebProxy.cs
index 91eef062a30b4842c2929183320c81a2440d0714..365535a056bb4b561f1eb55aef21e100c4da2305 100644 (file)
@@ -42,9 +42,7 @@ namespace System.Net
                bool bypassOnLocal;
                ArrayList bypassList;
                ICredentials credentials;
-#if NET_2_0
                bool useDefaultCredentials;
-#endif
 
                // Constructors
 
@@ -92,9 +90,7 @@ namespace System.Net
                        this.address = (Uri) serializationInfo.GetValue ("_ProxyAddress", typeof (Uri));
                        this.bypassOnLocal = serializationInfo.GetBoolean ("_BypassOnLocal");
                        this.bypassList = (ArrayList) serializationInfo.GetValue ("_BypassList", typeof (ArrayList));
-#if NET_2_0
                        this.useDefaultCredentials =  serializationInfo.GetBoolean ("_UseDefaultCredentials");
-#endif
                        this.credentials = null;
                        CheckBypassList ();
                }
@@ -133,15 +129,14 @@ namespace System.Net
                        set { credentials = value; }
                }
 
-#if NET_2_0
                [MonoTODO ("Does not affect Credentials, since CredentialCache.DefaultCredentials is not implemented.")]
                public bool UseDefaultCredentials {
                        get { return useDefaultCredentials; }
                        set { useDefaultCredentials = value; }
                }
-#endif
 
                // Methods
+               [Obsolete ("This method has been deprecated", false)]
                [MonoTODO("Can we get this info under windows from the system?")]
                public static WebProxy GetDefaultProxy ()
                {
@@ -163,10 +158,8 @@ namespace System.Net
 
                public bool IsBypassed (Uri host)
                {
-#if NET_2_0
                        if (host == null)
                                throw new ArgumentNullException ("host");
-#endif
 
                        if (host.IsLoopback && bypassOnLocal)
                                return true;
@@ -185,14 +178,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 {
@@ -222,15 +213,18 @@ namespace System.Net
                        }
                }
 
-               void ISerializable.GetObjectData (SerializationInfo serializationInfo,
-                                                 StreamingContext streamingContext)
+               protected virtual void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
                {
                        serializationInfo.AddValue ("_BypassOnLocal", bypassOnLocal);
                        serializationInfo.AddValue ("_ProxyAddress", address);
                        serializationInfo.AddValue ("_BypassList", bypassList);
-#if NET_2_0
                        serializationInfo.AddValue ("_UseDefaultCredentials", UseDefaultCredentials);
-#endif
+               }
+
+               void ISerializable.GetObjectData (SerializationInfo serializationInfo,
+                                                 StreamingContext streamingContext)
+               {
+                       GetObjectData (serializationInfo, streamingContext);
                }
 
                // Private Methods
@@ -249,7 +243,7 @@ namespace System.Net
                        if (address == null)
                                return null;
                                
-                       if (address.IndexOf ("://") == -1) 
+                       if (address.IndexOf ("://", StringComparison.Ordinal) == -1) 
                                address = "http://" + address;
 
                        return new Uri (address);