Refactoring proxy, part 2

This commit is contained in:
bao-qian
2016-06-19 16:18:43 +01:00
parent 764a372e9f
commit 3efeb4a0a6
41 changed files with 98 additions and 146 deletions

View File

@@ -14,8 +14,8 @@ using NHotkey.Wpf;
using Wox.Core;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
using Wox.ViewModel;
@@ -264,29 +264,27 @@ namespace Wox
private void OnTestProxyClick(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(_settings.ProxyServer))
if (string.IsNullOrEmpty(_settings.Proxy.Server))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
return;
}
if (_settings.ProxyPort > 0)
if (_settings.Proxy.Port <= 0)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
return;
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Infrastructure.Constant.Github);
request.Timeout = 1000 * 5;
request.ReadWriteTimeout = 1000 * 5;
if (string.IsNullOrEmpty(_settings.ProxyUserName) || string.IsNullOrEmpty(_settings.ProxyPassword))
if (string.IsNullOrEmpty(_settings.Proxy.UserName) || string.IsNullOrEmpty(_settings.Proxy.Password))
{
request.Proxy = new WebProxy(_settings.ProxyServer, _settings.ProxyPort);
request.Proxy = new WebProxy(_settings.Proxy.Server, _settings.Proxy.Port);
}
else
{
request.Proxy = new WebProxy(_settings.ProxyServer, _settings.ProxyPort)
request.Proxy = new WebProxy(_settings.Proxy.Server, _settings.Proxy.Port)
{
Credentials = new NetworkCredential(_settings.ProxyUserName, _settings.ProxyPassword)
Credentials = new NetworkCredential(_settings.Proxy.UserName, _settings.Proxy.Password)
};
}
try