diff --git a/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs b/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs
index 91b24ad1ae..0a595a4202 100644
--- a/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/ExecutablePlugin.cs
@@ -21,7 +21,7 @@ namespace Wox.Core.Plugin
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
- RedirectStandardError = true
+ RedirectStandardError = true,
};
}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCClientRequestModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCClientRequestModel.cs
new file mode 100644
index 0000000000..22cdb05b17
--- /dev/null
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCClientRequestModel.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
+ * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
+ * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
+ *
+ * When execute a query:
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCQueryResponseModel--------- client
+ *
+ * When execute a action (which mean user select an item in reulst item):
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCResponseModel-------------- client
+ *
+ */
+
+namespace Wox.Core.Plugin
+{
+ ///
+ /// Json RPC Request(in query response) that client sent to Wox
+ ///
+ public class JsonRPCClientRequestModel : JsonRPCRequestModel
+ {
+ public bool DontHideAfterAction { get; set; }
+
+ public override string ToString()
+ {
+ string rpc = base.ToString();
+ return rpc + "}";
+ }
+ }
+}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs
new file mode 100644
index 0000000000..7130d1e604
--- /dev/null
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
+ * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
+ * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
+ *
+ * When execute a query:
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCQueryResponseModel--------- client
+ *
+ * When execute a action (which mean user select an item in reulst item):
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCResponseModel-------------- client
+ *
+ */
+
+namespace Wox.Core.Plugin
+{
+ public class JsonRPCErrorModel
+ {
+ public int Code { get; set; }
+
+ public string Message { get; set; }
+
+ public string Data { get; set; }
+ }
+}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs
new file mode 100644
index 0000000000..9040a345c1
--- /dev/null
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
+ * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
+ * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
+ *
+ * When execute a query:
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCQueryResponseModel--------- client
+ *
+ * When execute a action (which mean user select an item in reulst item):
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCResponseModel-------------- client
+ *
+ */
+
+namespace Wox.Core.Plugin
+{
+ public class JsonRPCModelBase
+ {
+ public int Id { get; set; }
+ }
+}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs
index 0e825f3279..152e501203 100644
--- a/src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCPlugin.cs
@@ -19,11 +19,12 @@ namespace Wox.Core.Plugin
///
internal abstract class JsonRPCPlugin : IPlugin, IContextMenu
{
- protected PluginInitContext context;
+ protected PluginInitContext Context { get; set; }
+
public const string JsonRPC = "JsonRPC";
///
- /// The language this JsonRPCPlugin support
+ /// Gets or sets the language this JsonRPCPlugin support
///
public abstract string SupportedLanguage { get; set; }
@@ -67,21 +68,27 @@ namespace Wox.Core.Plugin
private List DeserializedResult(string output)
{
- if (!String.IsNullOrEmpty(output))
+ if (!string.IsNullOrEmpty(output))
{
List results = new List();
JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject(output);
- if (queryResponseModel.Result == null) return null;
+ if (queryResponseModel.Result == null)
+ {
+ return null;
+ }
foreach (JsonRPCResult result in queryResponseModel.Result)
{
JsonRPCResult result1 = result;
result.Action = c =>
{
- if (result1.JsonRPCAction == null) return false;
+ if (result1.JsonRPCAction == null)
+ {
+ return false;
+ }
- if (!String.IsNullOrEmpty(result1.JsonRPCAction.Method))
+ if (!string.IsNullOrEmpty(result1.JsonRPCAction.Method))
{
if (result1.JsonRPCAction.Method.StartsWith("Wox."))
{
@@ -92,7 +99,7 @@ namespace Wox.Core.Plugin
string actionResponse = ExecuteCallback(result1.JsonRPCAction);
JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject(actionResponse);
if (jsonRpcRequestModel != null
- && !String.IsNullOrEmpty(jsonRpcRequestModel.Method)
+ && !string.IsNullOrEmpty(jsonRpcRequestModel.Method)
&& jsonRpcRequestModel.Method.StartsWith("Wox."))
{
ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4), jsonRpcRequestModel.Parameters);
@@ -136,18 +143,21 @@ namespace Wox.Core.Plugin
///
/// Execute external program and return the output
///
- ///
- ///
- ///
+ /// file to execute
+ /// args to pass in to that exe
+ /// results
protected string Execute(string fileName, string arguments)
{
- ProcessStartInfo start = new ProcessStartInfo();
- start.FileName = fileName;
- start.Arguments = arguments;
- start.UseShellExecute = false;
- start.CreateNoWindow = true;
- start.RedirectStandardOutput = true;
- start.RedirectStandardError = true;
+ ProcessStartInfo start = new ProcessStartInfo
+ {
+ FileName = fileName,
+ Arguments = arguments,
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ };
+
return Execute(start);
}
@@ -206,7 +216,7 @@ namespace Wox.Core.Plugin
public void Init(PluginInitContext ctx)
{
- context = ctx;
+ Context = ctx;
}
}
}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCQueryResponseModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCQueryResponseModel.cs
new file mode 100644
index 0000000000..9ded1a4fcf
--- /dev/null
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCQueryResponseModel.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
+ * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
+ * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
+ *
+ * When execute a query:
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCQueryResponseModel--------- client
+ *
+ * When execute a action (which mean user select an item in reulst item):
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCResponseModel-------------- client
+ *
+ */
+
+using System.Collections.Generic;
+
+namespace Wox.Core.Plugin
+{
+ public class JsonRPCQueryResponseModel : JsonRPCResponseModel
+ {
+ public new List Result { get; set; }
+ }
+}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonPRCModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCRequestModel.cs
similarity index 61%
rename from src/modules/launcher/Wox.Core/Plugin/JsonPRCModel.cs
rename to src/modules/launcher/Wox.Core/Plugin/JsonRPCRequestModel.cs
index 5c75e11418..967cd1930b 100644
--- a/src/modules/launcher/Wox.Core/Plugin/JsonPRCModel.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCRequestModel.cs
@@ -16,38 +16,10 @@
*
*/
-using System.Collections.Generic;
using System.Linq;
-using Wox.Plugin;
namespace Wox.Core.Plugin
{
- public class JsonRPCErrorModel
- {
- public int Code { get; set; }
-
- public string Message { get; set; }
-
- public string Data { get; set; }
- }
-
- public class JsonRPCModelBase
- {
- public int Id { get; set; }
- }
-
- public class JsonRPCResponseModel : JsonRPCModelBase
- {
- public string Result { get; set; }
-
- public JsonRPCErrorModel Error { get; set; }
- }
-
- public class JsonRPCQueryResponseModel : JsonRPCResponseModel
- {
- public new List Result { get; set; }
- }
-
public class JsonRPCRequestModel : JsonRPCModelBase
{
public string Method { get; set; }
@@ -103,40 +75,4 @@ namespace Wox.Core.Plugin
.Replace(@"""", @"\\""""");
}
}
-
- ///
- /// Json RPC Request that Wox sent to client
- ///
- public class JsonRPCServerRequestModel : JsonRPCRequestModel
- {
- public override string ToString()
- {
- string rpc = base.ToString();
- return rpc + "}";
- }
- }
-
- ///
- /// Json RPC Request(in query response) that client sent to Wox
- ///
- public class JsonRPCClientRequestModel : JsonRPCRequestModel
- {
- public bool DontHideAfterAction { get; set; }
-
- public override string ToString()
- {
- string rpc = base.ToString();
- return rpc + "}";
- }
- }
-
- ///
- /// Represent the json-rpc result item that client send to Wox
- /// Typically, we will send back this request model to client after user select the result item
- /// But if the request method starts with "Wox.", we will invoke the public APIs we expose.
- ///
- public class JsonRPCResult : Result
- {
- public JsonRPCClientRequestModel JsonRPCAction { get; set; }
- }
}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs
new file mode 100644
index 0000000000..a6b5723a2b
--- /dev/null
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
+ * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
+ * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
+ *
+ * When execute a query:
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCQueryResponseModel--------- client
+ *
+ * When execute a action (which mean user select an item in reulst item):
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCResponseModel-------------- client
+ *
+ */
+
+namespace Wox.Core.Plugin
+{
+ public class JsonRPCResponseModel : JsonRPCModelBase
+ {
+ public string Result { get; set; }
+
+ public JsonRPCErrorModel Error { get; set; }
+ }
+}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs
new file mode 100644
index 0000000000..a9eb036957
--- /dev/null
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs
@@ -0,0 +1,32 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
+ * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
+ * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
+ *
+ * When execute a query:
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCQueryResponseModel--------- client
+ *
+ * When execute a action (which mean user select an item in reulst item):
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCResponseModel-------------- client
+ *
+ */
+
+using Wox.Plugin;
+
+namespace Wox.Core.Plugin
+{
+ ///
+ /// Represent the json-rpc result item that client send to Wox
+ /// Typically, we will send back this request model to client after user select the result item
+ /// But if the request method starts with "Wox.", we will invoke the public APIs we expose.
+ ///
+ public class JsonRPCResult : Result
+ {
+ public JsonRPCClientRequestModel JsonRPCAction { get; set; }
+ }
+}
diff --git a/src/modules/launcher/Wox.Core/Plugin/JsonRPCServerRequestModel.cs b/src/modules/launcher/Wox.Core/Plugin/JsonRPCServerRequestModel.cs
new file mode 100644
index 0000000000..a7d7f57b95
--- /dev/null
+++ b/src/modules/launcher/Wox.Core/Plugin/JsonRPCServerRequestModel.cs
@@ -0,0 +1,32 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
+ * like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
+ * "id" and "jsonrpc" in the request, since it's not so useful in our request model.
+ *
+ * When execute a query:
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCQueryResponseModel--------- client
+ *
+ * When execute a action (which mean user select an item in reulst item):
+ * Wox -------JsonRPCServerRequestModel--------> client
+ * Wox <------JsonRPCResponseModel-------------- client
+ *
+ */
+
+namespace Wox.Core.Plugin
+{
+ ///
+ /// Json RPC Request that Wox sent to client
+ ///
+ public class JsonRPCServerRequestModel : JsonRPCRequestModel
+ {
+ public override string ToString()
+ {
+ string rpc = base.ToString();
+ return rpc + "}";
+ }
+ }
+}
diff --git a/src/modules/launcher/Wox.Core/Plugin/PluginConfig.cs b/src/modules/launcher/Wox.Core/Plugin/PluginConfig.cs
index f0a3a13e75..9f86fe0a7b 100644
--- a/src/modules/launcher/Wox.Core/Plugin/PluginConfig.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/PluginConfig.cs
@@ -4,8 +4,8 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.IO;
+using System.Linq;
using Newtonsoft.Json;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
@@ -20,8 +20,8 @@ namespace Wox.Core.Plugin
///
/// Parse plugin metadata in giving directories
///
- ///
- ///
+ /// directories with plugins
+ /// List with plugin meta data
public static List Parse(string[] pluginDirectories)
{
PluginMetadatas.Clear();
diff --git a/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs b/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs
index d19fb540ea..1c1a316066 100644
--- a/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/PluginInstaller.cs
@@ -87,9 +87,7 @@ namespace Wox.Core.Plugin
// {
// Plugins.Initialize();
// }
- if (MessageBox.Show($"You have installed plugin {plugin.Name} successfully.{Environment.NewLine}" +
- "Restart Wox to take effect?",
- "Install plugin", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ if (MessageBox.Show($"You have installed plugin {plugin.Name} successfully.{Environment.NewLine} Restart Wox to take effect?", "Install plugin", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
PluginManager.API.RestartApp();
}
@@ -119,8 +117,9 @@ namespace Wox.Core.Plugin
{
throw new Exception(error);
}
-#endif
+#else
return null;
+#endif
}
if (!AllowedLanguage.IsAllowed(metadata.Language))
@@ -130,8 +129,9 @@ namespace Wox.Core.Plugin
{
throw new Exception(error);
}
-#endif
+#else
return null;
+#endif
}
if (!File.Exists(metadata.ExecuteFilePath))
@@ -141,8 +141,9 @@ namespace Wox.Core.Plugin
{
throw new Exception(error);
}
-#endif
+#else
return null;
+#endif
}
return metadata;
@@ -156,10 +157,15 @@ namespace Wox.Core.Plugin
/// overwrite
private static void UnZip(string zippedFile, string strDirectory, bool overWrite)
{
- if (strDirectory == "")
+ if (strDirectory == string.Empty)
+ {
strDirectory = Directory.GetCurrentDirectory();
+ }
+
if (!strDirectory.EndsWith("\\"))
- strDirectory = strDirectory + "\\";
+ {
+ strDirectory += "\\";
+ }
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zippedFile)))
{
@@ -167,18 +173,20 @@ namespace Wox.Core.Plugin
while ((theEntry = s.GetNextEntry()) != null)
{
- string directoryName = "";
- string pathToZip = "";
+ string directoryName = string.Empty;
+ string pathToZip = string.Empty;
pathToZip = theEntry.Name;
- if (pathToZip != "")
+ if (pathToZip != string.Empty)
+ {
directoryName = Path.GetDirectoryName(pathToZip) + "\\";
+ }
string fileName = Path.GetFileName(pathToZip);
Directory.CreateDirectory(strDirectory + directoryName);
- if (fileName != "")
+ if (fileName != string.Empty)
{
if ((File.Exists(strDirectory + directoryName + fileName) && overWrite) || (!File.Exists(strDirectory + directoryName + fileName)))
{
@@ -190,9 +198,13 @@ namespace Wox.Core.Plugin
int size = s.Read(data, 0, data.Length);
if (size > 0)
+ {
streamWriter.Write(data, 0, size);
+ }
else
+ {
break;
+ }
}
streamWriter.Close();
diff --git a/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs b/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs
index bd81d1e4d6..0406523b3e 100644
--- a/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/PluginManager.cs
@@ -24,20 +24,20 @@ namespace Wox.Core.Plugin
private static IEnumerable _contextMenuPlugins = new List();
///
- /// Directories that will hold Wox plugin directory
+ /// Gets directories that will hold Wox plugin directory
///
public static List AllPlugins { get; private set; }
+ public static IPublicAPI API { get; private set; }
+
public static readonly List GlobalPlugins = new List();
public static readonly Dictionary NonGlobalPlugins = new Dictionary();
-
- public static IPublicAPI API { private set; get; }
-
+ private static readonly string[] Directories = { Constant.PreinstalledDirectory, Constant.PluginsDirectory };
// todo happlebao, this should not be public, the indicator function should be embedded
- public static PluginSettings Settings;
+ public static PluginSettings Settings { get; set; }
+
private static List _metadatas;
- private static readonly string[] Directories = { Constant.PreinstalledDirectory, Constant.PluginsDirectory };
private static void ValidateUserDirectory()
{
@@ -74,7 +74,7 @@ namespace Wox.Core.Plugin
/// because InitializePlugins needs API, so LoadPlugins needs to be called first
/// todo happlebao The API should be removed
///
- ///
+ /// Plugin settings
public static void LoadPlugins(PluginSettings settings)
{
_metadatas = PluginConfig.Parse(Directories);
@@ -86,7 +86,6 @@ namespace Wox.Core.Plugin
///
/// Call initialize for all plugins
///
- /// return the list of failed to init plugins or null for none
public static void InitializePlugins(IPublicAPI api)
{
API = api;
@@ -100,7 +99,7 @@ namespace Wox.Core.Plugin
pair.Plugin.Init(new PluginInitContext
{
CurrentPluginMetadata = pair.Metadata,
- API = API
+ API = API,
});
});
pair.Metadata.InitTime += milliseconds;
@@ -118,7 +117,9 @@ namespace Wox.Core.Plugin
foreach (var plugin in AllPlugins)
{
if (IsGlobalPlugin(plugin.Metadata))
+ {
GlobalPlugins.Add(plugin);
+ }
// Plugins may have multiple ActionKeywords, eg. WebSearch
plugin.Metadata.ActionKeywords.Where(x => x != Query.GlobalPluginWildcardSign)
@@ -129,7 +130,7 @@ namespace Wox.Core.Plugin
if (failedPlugins.Any())
{
var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name));
- API.ShowMsg($"Fail to Init Plugins", $"Plugins: {failed} - fail to load and would be disabled, please contact plugin creator for help", "", false);
+ API.ShowMsg($"Fail to Init Plugins", $"Plugins: {failed} - fail to load and would be disabled, please contact plugin creator for help", string.Empty, false);
}
}
@@ -191,14 +192,15 @@ namespace Wox.Core.Plugin
///
/// get specified plugin, return null if not found
///
- ///
- ///
+ /// id of plugin
+ /// plugin
public static PluginPair GetPluginForId(string id)
{
return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id);
}
- public static IEnumerable GetPluginsForInterface() where T : IFeatures
+ public static IEnumerable GetPluginsForInterface()
+ where T : IFeatures
{
return AllPlugins.Where(p => p.Plugin is T);
}
@@ -278,7 +280,9 @@ namespace Wox.Core.Plugin
}
if (oldActionkeyword != Query.GlobalPluginWildcardSign)
+ {
NonGlobalPlugins.Remove(oldActionkeyword);
+ }
plugin.Metadata.ActionKeywords.Remove(oldActionkeyword);
}
diff --git a/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs b/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs
index ddb6d9f39d..0f1550b3c0 100644
--- a/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/PluginsLoader.cs
@@ -8,7 +8,6 @@ using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using Wox.Infrastructure;
-using Wox.Infrastructure.Logger;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
@@ -48,9 +47,10 @@ namespace Wox.Core.Plugin
}
catch (Exception e)
{
- Log.Exception($"|PluginsLoader.CSharpPlugins|Couldn't load assembly for {metadata.Name}", e);
+ Infrastructure.Logger.Log.Exception($"|PluginsLoader.CSharpPlugins|Couldn't load assembly for {metadata.Name}", e);
return;
}
+
var types = assembly.GetTypes();
Type type;
try
@@ -59,9 +59,10 @@ namespace Wox.Core.Plugin
}
catch (InvalidOperationException e)
{
- Log.Exception($"|PluginsLoader.CSharpPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
+ Infrastructure.Logger.Log.Exception($"|PluginsLoader.CSharpPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
return;
}
+
IPlugin plugin;
try
{
@@ -69,14 +70,14 @@ namespace Wox.Core.Plugin
}
catch (Exception e)
{
- Log.Exception($"|PluginsLoader.CSharpPlugins|Can't create instance for <{metadata.Name}>", e);
+ Infrastructure.Logger.Log.Exception($"|PluginsLoader.CSharpPlugins|Can't create instance for <{metadata.Name}>", e);
return;
}
#endif
PluginPair pair = new PluginPair
{
Plugin = plugin,
- Metadata = metadata
+ Metadata = metadata,
};
plugins.Add(pair);
});
@@ -93,7 +94,7 @@ namespace Wox.Core.Plugin
var plugins = metadatas.Select(metadata => new PluginPair
{
Plugin = new ExecutablePlugin(metadata.ExecuteFilePath),
- Metadata = metadata
+ Metadata = metadata,
});
return plugins;
}
diff --git a/src/modules/launcher/Wox.Core/Plugin/QueryBuilder.cs b/src/modules/launcher/Wox.Core/Plugin/QueryBuilder.cs
index b88aed8f7c..114c3bc9c4 100644
--- a/src/modules/launcher/Wox.Core/Plugin/QueryBuilder.cs
+++ b/src/modules/launcher/Wox.Core/Plugin/QueryBuilder.cs
@@ -46,7 +46,7 @@ namespace Wox.Core.Plugin
// Obsolete value initialisation
ActionName = actionKeyword,
- ActionParameters = actionParameters
+ ActionParameters = actionParameters,
};
return query;
diff --git a/src/modules/launcher/Wox.Core/Resource/AvailableLanguages.cs b/src/modules/launcher/Wox.Core/Resource/AvailableLanguages.cs
index 53a63b83c3..a24db68d4c 100644
--- a/src/modules/launcher/Wox.Core/Resource/AvailableLanguages.cs
+++ b/src/modules/launcher/Wox.Core/Resource/AvailableLanguages.cs
@@ -8,24 +8,41 @@ namespace Wox.Core.Resource
{
internal static class AvailableLanguages
{
- public static Language English = new Language("en", "English");
- public static Language Chinese = new Language("zh-cn", "中文");
- public static Language Chinese_TW = new Language("zh-tw", "中文(繁体)");
- public static Language Ukrainian = new Language("uk-UA", "Українська");
- public static Language Russian = new Language("ru", "Русский");
- public static Language French = new Language("fr", "Français");
- public static Language Japanese = new Language("ja", "日本語");
- public static Language Dutch = new Language("nl", "Dutch");
- public static Language Polish = new Language("pl", "Polski");
- public static Language Danish = new Language("da", "Dansk");
- public static Language German = new Language("de", "Deutsch");
- public static Language Korean = new Language("ko", "한국어");
- public static Language Serbian = new Language("sr", "Srpski");
- public static Language Portuguese_BR = new Language("pt-br", "Português (Brasil)");
- public static Language Italian = new Language("it", "Italiano");
- public static Language Norwegian_Bokmal = new Language("nb-NO", "Norsk Bokmål");
- public static Language Slovak = new Language("sk", "Slovenský");
- public static Language Turkish = new Language("tr", "Türkçe");
+ public static Language English { get; set; } = new Language("en", "English");
+
+ public static Language Chinese { get; set; } = new Language("zh-cn", "中文");
+
+ public static Language Chinese_TW { get; set; } = new Language("zh-tw", "中文(繁体)");
+
+ public static Language Ukrainian { get; set; } = new Language("uk-UA", "Українська");
+
+ public static Language Russian { get; set; } = new Language("ru", "Русский");
+
+ public static Language French { get; set; } = new Language("fr", "Français");
+
+ public static Language Japanese { get; set; } = new Language("ja", "日本語");
+
+ public static Language Dutch { get; set; } = new Language("nl", "Dutch");
+
+ public static Language Polish { get; set; } = new Language("pl", "Polski");
+
+ public static Language Danish { get; set; } = new Language("da", "Dansk");
+
+ public static Language German { get; set; } = new Language("de", "Deutsch");
+
+ public static Language Korean { get; set; } = new Language("ko", "한국어");
+
+ public static Language Serbian { get; set; } = new Language("sr", "Srpski");
+
+ public static Language Portuguese_BR { get; set; } = new Language("pt-br", "Português (Brasil)");
+
+ public static Language Italian { get; set; } = new Language("it", "Italiano");
+
+ public static Language Norwegian_Bokmal { get; set; } = new Language("nb-NO", "Norsk Bokmål");
+
+ public static Language Slovak { get; set; } = new Language("sk", "Slovenský");
+
+ public static Language Turkish { get; set; } = new Language("tr", "Türkçe");
public static List GetAvailableLanguages()
{
@@ -48,7 +65,7 @@ namespace Wox.Core.Resource
Italian,
Norwegian_Bokmal,
Slovak,
- Turkish
+ Turkish,
};
return languages;
}
diff --git a/src/modules/launcher/Wox.Core/Resource/FontHelper.cs b/src/modules/launcher/Wox.Core/Resource/FontHelper.cs
index dc64e24ce0..191cf8daad 100644
--- a/src/modules/launcher/Wox.Core/Resource/FontHelper.cs
+++ b/src/modules/launcher/Wox.Core/Resource/FontHelper.cs
@@ -11,15 +11,18 @@ namespace Wox.Core.Resource
{
public static class FontHelper
{
- static FontWeightConverter fontWeightConverter = new FontWeightConverter();
+ private static readonly FontWeightConverter _fontWeightConverter = new FontWeightConverter();
public static FontWeight GetFontWeightFromInvariantStringOrNormal(string value)
{
- if (value == null) return FontWeights.Normal;
+ if (value == null)
+ {
+ return FontWeights.Normal;
+ }
try
{
- return (FontWeight)fontWeightConverter.ConvertFromInvariantString(value);
+ return (FontWeight)_fontWeightConverter.ConvertFromInvariantString(value);
}
catch
{
@@ -27,15 +30,18 @@ namespace Wox.Core.Resource
}
}
- static FontStyleConverter fontStyleConverter = new FontStyleConverter();
+ private static readonly FontStyleConverter _fontStyleConverter = new FontStyleConverter();
public static FontStyle GetFontStyleFromInvariantStringOrNormal(string value)
{
- if (value == null) return FontStyles.Normal;
+ if (value == null)
+ {
+ return FontStyles.Normal;
+ }
try
{
- return (FontStyle)fontStyleConverter.ConvertFromInvariantString(value);
+ return (FontStyle)_fontStyleConverter.ConvertFromInvariantString(value);
}
catch
{
@@ -43,14 +49,18 @@ namespace Wox.Core.Resource
}
}
- static FontStretchConverter fontStretchConverter = new FontStretchConverter();
+ private static readonly FontStretchConverter _fontStretchConverter = new FontStretchConverter();
public static FontStretch GetFontStretchFromInvariantStringOrNormal(string value)
{
- if (value == null) return FontStretches.Normal;
+ if (value == null)
+ {
+ return FontStretches.Normal;
+ }
+
try
{
- return (FontStretch)fontStretchConverter.ConvertFromInvariantString(value);
+ return (FontStretch)_fontStretchConverter.ConvertFromInvariantString(value);
}
catch
{
@@ -62,9 +72,9 @@ namespace Wox.Core.Resource
{
return family.FamilyTypefaces.OrderBy(o =>
{
- return Math.Abs(o.Stretch.ToOpenTypeStretch() - FontStretches.Normal.ToOpenTypeStretch()) * 100 +
+ return (Math.Abs(o.Stretch.ToOpenTypeStretch() - FontStretches.Normal.ToOpenTypeStretch()) * 100) +
Math.Abs(o.Weight.ToOpenTypeWeight() - FontWeights.Normal.ToOpenTypeWeight()) +
- (o.Style == FontStyles.Normal ? 0 : o.Style == FontStyles.Oblique ? 1 : 2) * 1000;
+ ((o.Style == FontStyles.Normal ? 0 : o.Style == FontStyles.Oblique ? 1 : 2) * 1000);
}).FirstOrDefault() ?? family.FamilyTypefaces.FirstOrDefault();
}
diff --git a/src/modules/launcher/Wox.Core/Resource/Internationalization.cs b/src/modules/launcher/Wox.Core/Resource/Internationalization.cs
index a8a0aded21..32f5d41097 100644
--- a/src/modules/launcher/Wox.Core/Resource/Internationalization.cs
+++ b/src/modules/launcher/Wox.Core/Resource/Internationalization.cs
@@ -108,13 +108,19 @@ namespace Wox.Core.Resource
var languageToSet = GetLanguageByLanguageCode(languageCodeToSet);
if (Settings.ShouldUsePinyin)
+ {
return false;
+ }
if (languageToSet != AvailableLanguages.Chinese && languageToSet != AvailableLanguages.Chinese_TW)
+ {
return false;
+ }
if (MessageBox.Show("Do you want to turn on search with Pinyin?", string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
+ {
return false;
+ }
return true;
}
@@ -143,7 +149,7 @@ namespace Wox.Core.Resource
{
var r = new ResourceDictionary
{
- Source = new Uri(f, UriKind.Absolute)
+ Source = new Uri(f, UriKind.Absolute),
};
dicts.Add(r);
_oldResources.Add(r);
@@ -174,8 +180,11 @@ namespace Wox.Core.Resource
{
foreach (var p in PluginManager.GetPluginsForInterface())
{
- var pluginI18N = p.Plugin as IPluginI18n;
- if (pluginI18N == null) return;
+ if (!(p.Plugin is IPluginI18n pluginI18N))
+ {
+ return;
+ }
+
try
{
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
diff --git a/src/modules/launcher/Wox.Core/Wox.Core.csproj b/src/modules/launcher/Wox.Core/Wox.Core.csproj
index 17cf407ad4..8b68f72803 100644
--- a/src/modules/launcher/Wox.Core/Wox.Core.csproj
+++ b/src/modules/launcher/Wox.Core/Wox.Core.csproj
@@ -67,7 +67,7 @@
-
+
\ No newline at end of file