bool bypassOnLocal;
ArrayList bypassList;
ICredentials credentials;
-#if NET_2_0
bool useDefaultCredentials;
-#endif
// Constructors
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 ();
}
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 ()
{
public bool IsBypassed (Uri host)
{
-#if NET_2_0
if (host == null)
throw new ArgumentNullException ("host");
-#endif
if (host.IsLoopback && bypassOnLocal)
return true;
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 {
}
}
- 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
if (address == null)
return null;
- if (address.IndexOf ("://") == -1)
+ if (address.IndexOf ("://", StringComparison.Ordinal) == -1)
address = "http://" + address;
return new Uri (address);