Refactoring

This commit is contained in:
qianlifeng
2014-12-21 22:03:03 +08:00
parent c20314f83c
commit 2b211c2ba0
26 changed files with 168 additions and 273 deletions

View File

@@ -1,44 +0,0 @@
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin;
namespace Wox.Helper
{
public class HttpProxy : IHttpProxy
{
private static readonly HttpProxy instance = new HttpProxy();
private HttpProxy()
{
}
public static HttpProxy Instance
{
get { return instance; }
}
public bool Enabled
{
get { return UserSettingStorage.Instance.ProxyEnabled; }
}
public string Server
{
get { return UserSettingStorage.Instance.ProxyServer; }
}
public int Port
{
get { return UserSettingStorage.Instance.ProxyPort; }
}
public string UserName
{
get { return UserSettingStorage.Instance.ProxyUserName; }
}
public string Password
{
get { return UserSettingStorage.Instance.ProxyPassword; }
}
}
}

View File

@@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wox.Helper
{
public class WoxException : Exception
{
public WoxException(string msg)
: base(msg)
{
}
}
}

View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wox.Helper
{
public class WoxJsonPRCException : WoxException
{
public WoxJsonPRCException(string msg)
: base(msg)
{
}
}
}

View File

@@ -8,6 +8,7 @@ using NHotkey;
using NHotkey.Wpf;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Wox.Plugin;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using UserControl = System.Windows.Controls.UserControl;

View File

@@ -18,6 +18,7 @@ using Wox.Commands;
using Wox.Helper;
using Wox.ImageLoader;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Storage;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin;

View File

@@ -10,6 +10,7 @@ using System.Windows.Forms;
using Newtonsoft.Json;
using Wox.Helper;
using Wox.Helper.ErrorReporting;
using Wox.Infrastructure.Exceptions;
using Wox.Infrastructure.Logger;
using Wox.JsonRPC;
using Wox.Plugin;
@@ -142,7 +143,7 @@ namespace Wox.PluginLoader
string error = errorReader.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonPRCException(error));
ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonRPCException(error));
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Reflection;
using System.Windows.Forms;
using Newtonsoft.Json;
using Wox.Helper;
using Wox.Infrastructure.Exceptions;
using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin;

View File

@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Http;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin;

View File

@@ -2,6 +2,8 @@
using System.Diagnostics;
using System.IO;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Http;
using Wox.JsonRPC;
using Wox.Plugin;

View File

@@ -8,6 +8,7 @@ using System.Text;
using Newtonsoft.Json;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Http;
namespace Wox.Update
{
@@ -25,28 +26,20 @@ namespace Wox.Update
public Release CheckUpgrade(bool forceCheck = false)
{
if (checkedUpdate && !forceCheck) return newRelease;
string json = HttpRequest.Get(updateURL);
if (string.IsNullOrEmpty(json)) return null;
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(updateURL, HttpProxy.Instance);
Stream s = response.GetResponseStream();
if (s != null)
try
{
StreamReader reader = new StreamReader(s, Encoding.UTF8);
string json = reader.ReadToEnd();
try
{
newRelease = JsonConvert.DeserializeObject<Release>(json);
}
catch
newRelease = JsonConvert.DeserializeObject<Release>(json);
if (!IsNewerThanCurrent(newRelease))
{
newRelease = null;
}
checkedUpdate = true;
}
catch{}
if (!IsNewerThanCurrent(newRelease))
{
newRelease = null;
}
checkedUpdate = true;
return newRelease;
}

View File

@@ -136,7 +136,6 @@
<DependentUpon>WPFErrorReportingDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Helper\FontHelper.cs" />
<Compile Include="Helper\HttpProxy.cs" />
<Compile Include="ImageLoader\ImageLoader.cs" />
<Compile Include="Helper\SingleInstance.cs" />
<Compile Include="Helper\SyntaxSugars.cs" />
@@ -150,8 +149,6 @@
<Compile Include="Helper\DispatcherExtensions.cs" />
<Compile Include="Helper\DWMDropShadow.cs" />
<Compile Include="Helper\PluginInstaller.cs" />
<Compile Include="Helper\WoxException.cs" />
<Compile Include="Helper\WoxPythonException.cs" />
<Compile Include="HotkeyControl.xaml.cs">
<DependentUpon>HotkeyControl.xaml</DependentUpon>
</Compile>