{
public WebProxy() { }
protected WebProxy(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
- public WebProxy(string Address) { }
- public WebProxy(string Address, bool BypassOnLocal) { }
- public WebProxy(string Address, bool BypassOnLocal, string[] BypassList) { }
- public WebProxy(string Address, bool BypassOnLocal, string[] BypassList, System.Net.ICredentials Credentials) { }
+ public WebProxy(string? Address) { }
+ public WebProxy(string? Address, bool BypassOnLocal) { }
+ public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList) { }
+ public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList, System.Net.ICredentials? Credentials) { }
public WebProxy(string Host, int Port) { }
- public WebProxy(System.Uri Address) { }
- public WebProxy(System.Uri Address, bool BypassOnLocal) { }
- public WebProxy(System.Uri Address, bool BypassOnLocal, string[] BypassList) { }
- public WebProxy(System.Uri Address, bool BypassOnLocal, string[] BypassList, System.Net.ICredentials Credentials) { }
- public System.Uri Address { get { throw null; } set { } }
+ public WebProxy(System.Uri? Address) { }
+ public WebProxy(System.Uri? Address, bool BypassOnLocal) { }
+ public WebProxy(System.Uri? Address, bool BypassOnLocal, string[]? BypassList) { }
+ public WebProxy(System.Uri? Address, bool BypassOnLocal, string[]? BypassList, System.Net.ICredentials? Credentials) { }
+ public System.Uri? Address { get { throw null; } set { } }
public System.Collections.ArrayList BypassArrayList { get { throw null; } }
public string[] BypassList { get { throw null; } set { } }
public bool BypassProxyOnLocal { get { throw null; } set { } }
- public System.Net.ICredentials Credentials { get { throw null; } set { } }
+ public System.Net.ICredentials? Credentials { get { throw null; } set { } }
public bool UseDefaultCredentials { get { throw null; } set { } }
[System.ObsoleteAttribute("This method has been deprecated. Please use the proxy selected for you by default. https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.WebProxy GetDefaultProxy() { throw null; }
protected virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
- public System.Uri GetProxy(System.Uri destination) { throw null; }
+ public System.Uri? GetProxy(System.Uri destination) { throw null; }
public bool IsBypassed(System.Uri host) { throw null; }
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
}
{
public class WebProxy : IWebProxy, ISerializable
{
- private ArrayList _bypassList;
- private Regex[] _regExBypassList;
+ private ArrayList? _bypassList;
+ private Regex[]? _regexBypassList;
- public WebProxy() : this((Uri)null, false, null, null) { }
+ public WebProxy() : this((Uri?)null, false, null, null) { }
- public WebProxy(Uri Address) : this(Address, false, null, null) { }
+ public WebProxy(Uri? Address) : this(Address, false, null, null) { }
- public WebProxy(Uri Address, bool BypassOnLocal) : this(Address, BypassOnLocal, null, null) { }
+ public WebProxy(Uri? Address, bool BypassOnLocal) : this(Address, BypassOnLocal, null, null) { }
- public WebProxy(Uri Address, bool BypassOnLocal, string[] BypassList) : this(Address, BypassOnLocal, BypassList, null) { }
+ public WebProxy(Uri? Address, bool BypassOnLocal, string[]? BypassList) : this(Address, BypassOnLocal, BypassList, null) { }
- public WebProxy(Uri Address, bool BypassOnLocal, string[] BypassList, ICredentials Credentials)
+ public WebProxy(Uri? Address, bool BypassOnLocal, string[]? BypassList, ICredentials? Credentials)
{
this.Address = Address;
this.Credentials = Credentials;
if (BypassList != null)
{
_bypassList = new ArrayList(BypassList);
- UpdateRegExList(true);
+ UpdateRegexList(true);
}
}
{
}
- public WebProxy(string Address)
+ public WebProxy(string? Address)
: this(CreateProxyUri(Address), false, null, null)
{
}
- public WebProxy(string Address, bool BypassOnLocal)
+ public WebProxy(string? Address, bool BypassOnLocal)
: this(CreateProxyUri(Address), BypassOnLocal, null, null)
{
}
- public WebProxy(string Address, bool BypassOnLocal, string[] BypassList)
+ public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList)
: this(CreateProxyUri(Address), BypassOnLocal, BypassList, null)
{
}
- public WebProxy(string Address, bool BypassOnLocal, string[] BypassList, ICredentials Credentials)
+ public WebProxy(string? Address, bool BypassOnLocal, string[]? BypassList, ICredentials? Credentials)
: this(CreateProxyUri(Address), BypassOnLocal, BypassList, Credentials)
{
}
- public Uri Address { get; set; }
+ public Uri? Address { get; set; }
public bool BypassProxyOnLocal { get; set; }
set
{
_bypassList = new ArrayList(value);
- UpdateRegExList(true);
+ UpdateRegexList(true);
}
}
public ArrayList BypassArrayList => _bypassList ?? (_bypassList = new ArrayList());
- public ICredentials Credentials { get; set; }
+ public ICredentials? Credentials { get; set; }
public bool UseDefaultCredentials
{
set { Credentials = value ? CredentialCache.DefaultCredentials : null; }
}
- public Uri GetProxy(Uri destination)
+ public Uri? GetProxy(Uri destination)
{
if (destination == null)
{
return IsBypassed(destination) ? destination : Address;
}
- private static Uri CreateProxyUri(string address) =>
+ private static Uri? CreateProxyUri(string? address) =>
address == null ? null :
address.IndexOf("://", StringComparison.Ordinal) == -1 ? new Uri("http://" + address) :
new Uri(address);
- private void UpdateRegExList(bool canThrow)
+ private void UpdateRegexList(bool canThrow)
{
- Regex[] regExBypassList = null;
- ArrayList bypassList = _bypassList;
+ Regex[]? regexBypassList = null;
+ ArrayList? bypassList = _bypassList;
try
{
if (bypassList != null && bypassList.Count > 0)
{
- regExBypassList = new Regex[bypassList.Count];
+ regexBypassList = new Regex[bypassList.Count];
for (int i = 0; i < bypassList.Count; i++)
{
- regExBypassList[i] = new Regex((string)bypassList[i], RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
+ regexBypassList[i] = new Regex((string)bypassList[i]!, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
}
}
}
{
if (!canThrow)
{
- _regExBypassList = null;
+ _regexBypassList = null;
return;
}
throw;
}
// Update field here, as it could throw earlier in the loop
- _regExBypassList = regExBypassList;
+ _regexBypassList = regexBypassList;
}
private bool IsMatchInBypassList(Uri input)
{
- UpdateRegExList(false);
+ UpdateRegexList(false);
- if (_regExBypassList != null)
+ if (_regexBypassList != null)
{
string matchUriString = input.IsDefaultPort ?
input.Scheme + "://" + input.Host :
input.Scheme + "://" + input.Host + ":" + input.Port.ToString();
- foreach (Regex r in _regExBypassList)
+ foreach (Regex r in _regexBypassList)
{
if (r.IsMatch(matchUriString))
{
string hostString = host.Host;
- IPAddress hostAddress;
- if (IPAddress.TryParse(hostString, out hostAddress))
+ if (IPAddress.TryParse(hostString, out IPAddress? hostAddress))
{
return IPAddress.IsLoopback(hostAddress) || IsAddressLocal(hostAddress);
}