ReSharper: remove redundant code

This commit is contained in:
bao-qian
2016-01-06 21:34:42 +00:00
parent ae42c4df16
commit 0daa3a8f57
65 changed files with 279 additions and 250 deletions

View File

@@ -29,7 +29,7 @@ namespace Wox.Core.Plugin
foreach (Type type in types)
{
PluginPair pair = new PluginPair()
PluginPair pair = new PluginPair
{
Plugin = Activator.CreateInstance(type) as IPlugin,
Metadata = metadata
@@ -38,7 +38,7 @@ namespace Wox.Core.Plugin
plugins.Add(pair);
}
}
catch (System.Exception e)
catch (Exception e)
{
Log.Error(new WoxPluginException(metadata.Name, $"Couldn't load plugin", e));
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@@ -41,7 +42,7 @@ namespace Wox.Core.Plugin
foreach (JsonRPCResult result in queryResponseModel.Result)
{
JsonRPCResult result1 = result;
result.Action = (c) =>
result.Action = c =>
{
if (result1.JsonRPCAction == null) return false;
@@ -72,7 +73,7 @@ namespace Wox.Core.Plugin
}
return results;
}
catch (System.Exception e)
catch (Exception e)
{
Log.Error(e);
}
@@ -89,7 +90,7 @@ namespace Wox.Core.Plugin
{
methodInfo.Invoke(PluginManager.API, parameters);
}
catch (System.Exception)
catch (Exception)
{
#if (DEBUG)
{
@@ -150,7 +151,7 @@ namespace Wox.Core.Plugin
}
}
}
catch(System.Exception e)
catch(Exception e)
{
throw new WoxJsonRPCException(e.Message);
}

View File

@@ -11,7 +11,7 @@ namespace Wox.Core.Plugin
T jsonRPCPlugin = new T();
List<PluginMetadata> jsonRPCPluginMetadatas = pluginMetadatas.Where(o => o.Language.ToUpper() == jsonRPCPlugin.SupportedLanguage.ToUpper()).ToList();
return jsonRPCPluginMetadatas.Select(metadata => new PluginPair()
return jsonRPCPluginMetadatas.Select(metadata => new PluginPair
{
Plugin = new T(), //every JsonRPC plugin should has its own plugin instance
Metadata = metadata

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
@@ -45,7 +46,7 @@ namespace Wox.Core.Plugin
Directory.Delete(directory, true);
continue;
}
catch (System.Exception e)
catch (Exception e)
{
Log.Fatal(e);
}
@@ -77,7 +78,7 @@ namespace Wox.Core.Plugin
// for plugin still use old ActionKeyword
metadata.ActionKeyword = metadata.ActionKeywords?[0];
}
catch (System.Exception e)
catch (Exception e)
{
string msg = $"Parse plugin config {configPath} failed: json format is not valid";
Log.Error(new WoxException(msg));

View File

@@ -107,12 +107,12 @@ namespace Wox.Core.Plugin
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
metadata.PluginDirectory = pluginDirectory;
}
catch (System.Exception)
catch (Exception)
{
string error = $"Parse plugin config {configPath} failed: json format is not valid";
#if (DEBUG)
{
throw new System.Exception(error);
throw new Exception(error);
}
#endif
return null;
@@ -124,7 +124,7 @@ namespace Wox.Core.Plugin
string error = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}";
#if (DEBUG)
{
throw new System.Exception(error);
throw new Exception(error);
}
#endif
return null;
@@ -134,7 +134,7 @@ namespace Wox.Core.Plugin
string error = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist";
#if (DEBUG)
{
throw new System.Exception(error);
throw new Exception(error);
}
#endif
return null;

View File

@@ -41,8 +41,8 @@ namespace Wox.Core.Plugin
protected override string ExecuteQuery(Query query)
{
JsonRPCServerRequestModel request = new JsonRPCServerRequestModel()
{
JsonRPCServerRequestModel request = new JsonRPCServerRequestModel
{
Method = "query",
Parameters = new object[] { query.GetAllRemainingParameter() },
HttpProxy = HttpProxy.Instance

View File

@@ -35,7 +35,7 @@ namespace Wox.Core.Theme
{
Directory.CreateDirectory(pluginDirectory);
}
catch (System.Exception e)
catch (Exception e)
{
Log.Error(e);
}
@@ -51,7 +51,7 @@ namespace Wox.Core.Theme
themePath = GetThemePath("Dark");
if (string.IsNullOrEmpty(themePath))
{
throw new System.Exception("Change theme failed");
throw new Exception("Change theme failed");
}
}
@@ -94,8 +94,8 @@ namespace Wox.Core.Theme
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight));
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStretch));
Setter[] setters = new Setter[] { fontFamily, fontStyle, fontWeight, fontStretch };
Array.ForEach(new Style[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
}
return dict;
}

View File

@@ -9,7 +9,7 @@ namespace Wox.Core.Updater
public int MINOR { get; set; }
public int PATCH { get; set; }
public SemanticVersion(System.Version version)
public SemanticVersion(Version version)
{
MAJOR = version.Major;
MINOR = version.Minor;

View File

@@ -92,7 +92,7 @@ namespace Wox.Core.Updater
StartUpdate();
}
}
catch (System.Exception e)
catch (Exception e)
{
Log.Error(e);
}
@@ -112,7 +112,7 @@ namespace Wox.Core.Updater
{
((UpdateProcessAsyncResult)asyncResult).EndInvoke();
}
catch (System.Exception e)
catch (Exception e)
{
Log.Error(e);
updManager.CleanUp();
@@ -148,7 +148,7 @@ namespace Wox.Core.Updater
{
UpdateManager.Instance.ApplyUpdates(true, UserSettingStorage.Instance.EnableUpdateLog, false);
}
catch (System.Exception e)
catch (Exception e)
{
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
Log.Error(e);

View File

@@ -15,30 +15,30 @@ namespace Wox.Core.Updater
public WoxUpdateSource(string feedUrl,IWebProxy proxy)
{
this.FeedUrl = feedUrl;
this.Proxy = proxy;
FeedUrl = feedUrl;
Proxy = proxy;
}
private void TryResolvingHost()
{
Uri uri = new Uri(this.FeedUrl);
Uri uri = new Uri(FeedUrl);
try
{
Dns.GetHostEntry(uri.Host);
}
catch (System.Exception ex)
catch (Exception ex)
{
throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", (object)uri.Host), WebExceptionStatus.ConnectFailure);
throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", uri.Host), WebExceptionStatus.ConnectFailure);
}
}
public string GetUpdatesFeed()
{
this.TryResolvingHost();
TryResolvingHost();
string str = string.Empty;
WebRequest webRequest = WebRequest.Create(this.FeedUrl);
WebRequest webRequest = WebRequest.Create(FeedUrl);
webRequest.Method = "GET";
webRequest.Proxy = this.Proxy;
webRequest.Proxy = Proxy;
using (WebResponse response = webRequest.GetResponse())
{
Stream responseStream = response.GetResponseStream();
@@ -56,7 +56,7 @@ namespace Wox.Core.Updater
if (!string.IsNullOrEmpty(baseUrl) && !baseUrl.EndsWith("/"))
baseUrl += "/";
FileDownloader fileDownloader = !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) ? (string.IsNullOrEmpty(baseUrl) ? new FileDownloader(url) : new FileDownloader(new Uri(new Uri(baseUrl), url))) : new FileDownloader(new Uri(new Uri(baseUrl, UriKind.Absolute), url))) : new FileDownloader(url);
fileDownloader.Proxy = this.Proxy;
fileDownloader.Proxy = Proxy;
if (string.IsNullOrEmpty(tempLocation) || !Directory.Exists(Path.GetDirectoryName(tempLocation)))
tempLocation = Path.GetTempFileName();
return fileDownloader.DownloadToFile(tempLocation, onProgress);

View File

@@ -172,7 +172,7 @@ namespace Wox.Core.UserSettings
var customizedPluginConfig = CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID);
if (customizedPluginConfig == null)
{
CustomizedPluginConfigs.Add(new CustomizedPluginConfig()
CustomizedPluginConfigs.Add(new CustomizedPluginConfig
{
Disabled = false,
ID = metadata.ID,

View File

@@ -18,7 +18,7 @@ namespace Wox.Core.i18n
Chinese,
Chinese_TW,
Russian,
French,
French
};
return languages;
}

View File

@@ -30,7 +30,7 @@ namespace Wox.Core.i18n
{
Directory.CreateDirectory(DefaultDirectory);
}
catch (System.Exception e)
catch (Exception e)
{
Log.Error(e);
}
@@ -64,7 +64,7 @@ namespace Wox.Core.i18n
path = GetLanguagePath(AvailableLanguages.English);
if (string.IsNullOrEmpty(path))
{
throw new System.Exception("Change Language failed");
throw new Exception("Change Language failed");
}
}
@@ -115,7 +115,7 @@ namespace Wox.Core.i18n
pluginPair.Metadata.Name = pluginI18n.GetTranslatedPluginTitle();
pluginPair.Metadata.Description = pluginI18n.GetTranslatedPluginDescription();
}
catch (System.Exception e)
catch (Exception e)
{
var woxPluginException = new WoxPluginException(pluginPair.Metadata.Name, "Update Plugin metadata translation failed:", e);
Log.Error(woxPluginException);