public void DisableProxy() { if (_proxy != null) { _proxy = null; ProxyUpdated?.BeginInvoke(this, EventArgs.Empty, null, null); } }
public void ConfigureProxy(NetProxyType proxyType, string proxyAddress, int proxyPort, NetworkCredential proxyCredentials) { _proxyAddress = proxyAddress; _proxyPort = proxyPort; _proxyCredentials = proxyCredentials; switch (proxyType) { case NetProxyType.Http: _proxy = new NetProxy(new WebProxyEx(new Uri("http://" + _proxyAddress + ":" + _proxyPort), false, new string[] { }, _proxyCredentials)); break; case NetProxyType.Socks5: _proxy = new NetProxy(new SocksClient(_proxyAddress, _proxyPort, _proxyCredentials)); break; default: _proxy = null; break; } ProxyUpdated?.BeginInvoke(this, EventArgs.Empty, null, null); }