mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 14:41:21 +08:00
Refactoring
This commit is contained in:
parent
c20314f83c
commit
2b211c2ba0
@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Helper
|
||||
namespace Wox.Infrastructure.Exceptions
|
||||
{
|
||||
public class WoxException : Exception
|
||||
{
|
14
Wox.Infrastructure/Exceptions/WoxHttpException.cs
Normal file
14
Wox.Infrastructure/Exceptions/WoxHttpException.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Infrastructure.Exceptions
|
||||
{
|
||||
public class WoxHttpException :WoxException
|
||||
{
|
||||
public WoxHttpException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
10
Wox.Infrastructure/Exceptions/WoxJsonRPCException.cs
Normal file
10
Wox.Infrastructure/Exceptions/WoxJsonRPCException.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Wox.Infrastructure.Exceptions
|
||||
{
|
||||
public class WoxJsonRPCException : WoxException
|
||||
{
|
||||
public WoxJsonRPCException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
namespace Wox.Infrastructure.Hotkey
|
||||
{
|
||||
public enum KeyEvent : int
|
||||
{
|
@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
namespace Wox.Infrastructure.Hotkey
|
||||
{
|
||||
public class HotkeyModel
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Helper
|
||||
namespace Wox.Infrastructure.Http
|
||||
{
|
||||
public class HttpProxy : IHttpProxy
|
||||
{
|
61
Wox.Infrastructure/Http/HttpRequest.cs
Normal file
61
Wox.Infrastructure/Http/HttpRequest.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.Http
|
||||
{
|
||||
public class HttpRequest
|
||||
{
|
||||
public static string Get(string url, string encoding = "UTF8")
|
||||
{
|
||||
return Get(url, encoding, HttpProxy.Instance);
|
||||
}
|
||||
|
||||
private static string Get(string url, string encoding, IHttpProxy proxy)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return string.Empty;
|
||||
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.Method = "GET";
|
||||
request.Timeout = 10 * 1000;
|
||||
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
|
||||
{
|
||||
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port)
|
||||
{
|
||||
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
||||
if (response != null)
|
||||
{
|
||||
Stream stream = response.GetResponseStream();
|
||||
if (stream != null)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(encoding)))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
//From:http://blog.csdn.net/zhoufoxcn/article/details/6404236
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public class HttpRequest
|
||||
{
|
||||
private static readonly string DefaultUserAgent = "Wox/" + Assembly.GetEntryAssembly().GetName().Version.ToString() + " (+https://github.com/qianlifeng/Wox)";
|
||||
|
||||
|
||||
public static HttpWebResponse CreateGetHttpResponse(string url, IHttpProxy proxy)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException("url");
|
||||
}
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
|
||||
{
|
||||
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
|
||||
}
|
||||
else
|
||||
{
|
||||
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
|
||||
request.Proxy.Credentials = new NetworkCredential(proxy.UserName, proxy.Password);
|
||||
}
|
||||
}
|
||||
request.Method = "GET";
|
||||
request.UserAgent = DefaultUserAgent;
|
||||
return request.GetResponse() as HttpWebResponse;
|
||||
}
|
||||
|
||||
public static HttpWebResponse CreateGetHttpResponse(string url, int? timeout, string userAgent, CookieCollection cookies)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException("url");
|
||||
}
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.Method = "GET";
|
||||
request.UserAgent = DefaultUserAgent;
|
||||
if (!string.IsNullOrEmpty(userAgent))
|
||||
{
|
||||
request.UserAgent = userAgent;
|
||||
}
|
||||
if (timeout.HasValue)
|
||||
{
|
||||
request.Timeout = timeout.Value;
|
||||
}
|
||||
if (cookies != null)
|
||||
{
|
||||
request.CookieContainer = new CookieContainer();
|
||||
request.CookieContainer.Add(cookies);
|
||||
}
|
||||
return request.GetResponse() as HttpWebResponse;
|
||||
}
|
||||
|
||||
public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary<string, string> parameters, int? timeout, string userAgent, Encoding requestEncoding, CookieCollection cookies)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException("url");
|
||||
}
|
||||
if (requestEncoding == null)
|
||||
{
|
||||
throw new ArgumentNullException("requestEncoding");
|
||||
}
|
||||
HttpWebRequest request = null;
|
||||
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.ProtocolVersion = HttpVersion.Version10;
|
||||
}
|
||||
else
|
||||
{
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
}
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
if (!string.IsNullOrEmpty(userAgent))
|
||||
{
|
||||
request.UserAgent = userAgent;
|
||||
}
|
||||
else
|
||||
{
|
||||
request.UserAgent = DefaultUserAgent;
|
||||
}
|
||||
|
||||
if (timeout.HasValue)
|
||||
{
|
||||
request.Timeout = timeout.Value;
|
||||
}
|
||||
if (cookies != null)
|
||||
{
|
||||
request.CookieContainer = new CookieContainer();
|
||||
request.CookieContainer.Add(cookies);
|
||||
}
|
||||
if (!(parameters == null || parameters.Count == 0))
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (string key in parameters.Keys)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
buffer.AppendFormat("&{0}={1}", key, parameters[key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.AppendFormat("{0}={1}", key, parameters[key]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
byte[] data = requestEncoding.GetBytes(buffer.ToString());
|
||||
using (Stream stream = request.GetRequestStream())
|
||||
{
|
||||
stream.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
return request.GetResponse() as HttpWebResponse;
|
||||
}
|
||||
|
||||
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
public List<ProgramSource> ProgramSources { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public List<FolderLink> FolderLinks { get; set; } //Aaron
|
||||
public List<FolderLink> FolderLinks { get; set; }
|
||||
|
||||
public List<CustomizedPluginConfig> CustomizedPluginConfigs { get; set; }
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public class StringNullOrEmptyToVisibilityConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -56,6 +56,10 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Exceptions\WoxException.cs" />
|
||||
<Compile Include="Exceptions\WoxHttpException.cs" />
|
||||
<Compile Include="Exceptions\WoxJsonRPCException.cs" />
|
||||
<Compile Include="Http\HttpProxy.cs" />
|
||||
<Compile Include="Logger\Log.cs" />
|
||||
<Compile Include="PeHeaderReader.cs" />
|
||||
<Compile Include="Storage\BinaryStorage.cs" />
|
||||
@ -66,11 +70,11 @@
|
||||
<Compile Include="Timeit.cs" />
|
||||
<Compile Include="Unidecoder.Characters.cs" />
|
||||
<Compile Include="ChineseToPinYin.cs" />
|
||||
<Compile Include="HttpRequest.cs" />
|
||||
<Compile Include="Http\HttpRequest.cs" />
|
||||
<Compile Include="Storage\BaseStorage.cs" />
|
||||
<Compile Include="FuzzyMatcher.cs" />
|
||||
<Compile Include="GlobalHotkey.cs" />
|
||||
<Compile Include="HotkeyModel.cs" />
|
||||
<Compile Include="Hotkey\GlobalHotkey.cs" />
|
||||
<Compile Include="Hotkey\HotkeyModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
|
||||
<Compile Include="Storage\UserSettings\UserSettingStorage.cs" />
|
||||
@ -78,7 +82,6 @@
|
||||
<Compile Include="Storage\UserSettings\ProgramSource.cs" />
|
||||
<Compile Include="Storage\UserSettings\WebSearch.cs" />
|
||||
<Compile Include="StringEmptyConverter.cs" />
|
||||
<Compile Include="StringNullOrEmptyToVisibilityConverter.cs" />
|
||||
<Compile Include="Unidecoder.cs" />
|
||||
<Compile Include="WindowsShellRun.cs" />
|
||||
</ItemGroup>
|
||||
@ -91,6 +94,7 @@
|
||||
<Name>Wox.Plugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -9,6 +9,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
using YAMP.Numerics;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.SuggestionSources
|
||||
@ -19,21 +20,19 @@ namespace Wox.Plugin.SystemPlugins.SuggestionSources
|
||||
|
||||
public override List<string> GetSuggestions(string query)
|
||||
{
|
||||
var result = HttpRequest.Get("http://suggestion.baidu.com/su?json=1&wd=" + Uri.EscapeUriString(query), "GB2312");
|
||||
if (string.IsNullOrEmpty(result)) return new List<string>();
|
||||
|
||||
Match match = reg.Match(result);
|
||||
if (match.Success)
|
||||
{
|
||||
JContainer json = null;
|
||||
try
|
||||
{
|
||||
var response =
|
||||
HttpRequest.CreateGetHttpResponse(
|
||||
"http://suggestion.baidu.com/su?json=1&wd=" + Uri.EscapeUriString(query), null,
|
||||
null, null);
|
||||
var stream = response.GetResponseStream();
|
||||
json =JsonConvert.DeserializeObject(match.Groups[1].Value) as JContainer;
|
||||
}
|
||||
catch{}
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
var body = new StreamReader(stream, Encoding.GetEncoding("GB2312")).ReadToEnd();
|
||||
Match m = reg.Match(body);
|
||||
if (m.Success)
|
||||
{
|
||||
var json = JsonConvert.DeserializeObject(m.Groups[1].Value) as JContainer;
|
||||
if (json != null)
|
||||
{
|
||||
var results = json["s"] as JArray;
|
||||
@ -43,12 +42,8 @@ namespace Wox.Plugin.SystemPlugins.SuggestionSources
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return null;
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
using YAMP.Numerics;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.SuggestionSources
|
||||
@ -16,18 +17,12 @@ namespace Wox.Plugin.SystemPlugins.SuggestionSources
|
||||
{
|
||||
public override List<string> GetSuggestions(string query)
|
||||
{
|
||||
var result = HttpRequest.Get("https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query));
|
||||
if (string.IsNullOrEmpty(result)) return new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
var response =
|
||||
HttpRequest.CreateGetHttpResponse(
|
||||
"https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query), null,
|
||||
null, null);
|
||||
var stream = response.GetResponseStream();
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
var body = new StreamReader(stream).ReadToEnd();
|
||||
var json = JsonConvert.DeserializeObject(body) as JContainer;
|
||||
JContainer json = JsonConvert.DeserializeObject(result) as JContainer;
|
||||
if (json != null)
|
||||
{
|
||||
var results = json[1] as JContainer;
|
||||
@ -37,11 +32,9 @@ namespace Wox.Plugin.SystemPlugins.SuggestionSources
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
catch { }
|
||||
|
||||
return null;
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Plugin
|
||||
{
|
||||
public class PythonResult : Result
|
||||
{
|
||||
public string ActionName { get; set; }
|
||||
public string ActionPara { get; set; }
|
||||
}
|
||||
}
|
@ -55,7 +55,6 @@
|
||||
<Compile Include="PluginMetadata.cs" />
|
||||
<Compile Include="PluginType.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PythonResult.cs" />
|
||||
<Compile Include="Query.cs" />
|
||||
<Compile Include="Result.cs" />
|
||||
<Compile Include="ActionContext.cs" />
|
||||
|
21
Wox.Test/Infrastructure/HttpRequestTest.cs
Normal file
21
Wox.Test/Infrastructure/HttpRequestTest.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
|
||||
namespace Wox.Test.Infrastructure
|
||||
{
|
||||
[TestFixture]
|
||||
public class HttpRequestTest
|
||||
{
|
||||
[Test]
|
||||
public void RequestTest()
|
||||
{
|
||||
string results = HttpRequest.Get("https://www.bing.com");
|
||||
Assert.IsNotNullOrEmpty(results);
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FuzzyMatcherTest.cs" />
|
||||
<Compile Include="Infrastructure\HttpRequestTest.cs" />
|
||||
<Compile Include="QueryTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UrlPluginTest.cs" />
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
StreamReader reader = new StreamReader(s, Encoding.UTF8);
|
||||
string json = reader.ReadToEnd();
|
||||
try
|
||||
{
|
||||
newRelease = JsonConvert.DeserializeObject<Release>(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsNewerThanCurrent(newRelease))
|
||||
{
|
||||
newRelease = null;
|
||||
}
|
||||
|
||||
checkedUpdate = true;
|
||||
}
|
||||
catch{}
|
||||
|
||||
return newRelease;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user