mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 10:19:20 +08:00
style cop wox.core whitespace changes (#5744)
* whitespace changes * undoing csproj tweak to keep stylecop off
This commit is contained in:
parent
b95a1fb604
commit
d7994ca67d
@ -10,6 +10,7 @@ namespace Wox.Core.Plugin
|
||||
internal class ExecutablePlugin : JsonRPCPlugin
|
||||
{
|
||||
private readonly ProcessStartInfo _startInfo;
|
||||
|
||||
public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable;
|
||||
|
||||
public ExecutablePlugin(string filename)
|
||||
|
@ -1,4 +1,7 @@
|
||||
|
||||
// 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.
|
||||
@ -74,18 +77,22 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
|
||||
if (parameter is string)
|
||||
{
|
||||
return string.Format(@"\""{0}\""", ReplaceEscapes(parameter.ToString()));
|
||||
}
|
||||
|
||||
if (parameter is int || parameter is float || parameter is double)
|
||||
{
|
||||
return string.Format(@"{0}", parameter);
|
||||
}
|
||||
|
||||
if (parameter is bool)
|
||||
{
|
||||
return string.Format(@"{0}", parameter.ToString().ToLower());
|
||||
}
|
||||
|
||||
return parameter.ToString();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@ namespace Wox.Core.Plugin
|
||||
public abstract string SupportedLanguage { get; set; }
|
||||
|
||||
protected abstract string ExecuteQuery(Query query);
|
||||
|
||||
protected abstract string ExecuteCallback(JsonRPCRequestModel rpcRequest);
|
||||
|
||||
protected abstract string ExecuteContextMenu(Result selectedResult);
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
@ -97,10 +99,12 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !result1.JsonRPCAction.DontHideAfterAction;
|
||||
};
|
||||
results.Add(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
else
|
||||
@ -120,7 +124,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
#if (DEBUG)
|
||||
#if DEBUG
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ using Wox.Plugin;
|
||||
|
||||
namespace Wox.Core.Plugin
|
||||
{
|
||||
|
||||
internal abstract class PluginConfig
|
||||
{
|
||||
private const string PluginConfigName = "plugin.json";
|
||||
@ -72,8 +71,10 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
|
||||
// for plugins which doesn't has ActionKeywords key
|
||||
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> { metadata.ActionKeyword };
|
||||
|
||||
// for plugin still use old ActionKeyword
|
||||
metadata.ActionKeyword = metadata.ActionKeywords?[0];
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
Directory.Delete(tempFolder, true);
|
||||
}
|
||||
|
||||
UnZip(path, tempFolder, true);
|
||||
|
||||
string iniPath = Path.Combine(tempFolder, "plugin.json");
|
||||
@ -114,7 +115,7 @@ namespace Wox.Core.Plugin
|
||||
catch (Exception)
|
||||
{
|
||||
string error = $"Parse plugin config {configPath} failed: json format is not valid";
|
||||
#if (DEBUG)
|
||||
#if DEBUG
|
||||
{
|
||||
throw new Exception(error);
|
||||
}
|
||||
@ -125,17 +126,18 @@ namespace Wox.Core.Plugin
|
||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||
{
|
||||
string error = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}";
|
||||
#if (DEBUG)
|
||||
#if DEBUG
|
||||
{
|
||||
throw new Exception(error);
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!File.Exists(metadata.ExecuteFilePath))
|
||||
{
|
||||
string error = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist";
|
||||
#if (DEBUG)
|
||||
#if DEBUG
|
||||
{
|
||||
throw new Exception(error);
|
||||
}
|
||||
@ -192,6 +194,7 @@ namespace Wox.Core.Plugin
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
streamWriter.Close();
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ namespace Wox.Core.Plugin
|
||||
/// <summary>
|
||||
/// Directories that will hold Wox plugin directory
|
||||
/// </summary>
|
||||
|
||||
public static List<PluginPair> AllPlugins { get; private set; }
|
||||
|
||||
public static readonly List<PluginPair> GlobalPlugins = new List<PluginPair>();
|
||||
public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new Dictionary<string, PluginPair>();
|
||||
|
||||
@ -255,6 +255,7 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
NonGlobalPlugins[newActionKeyword] = plugin;
|
||||
}
|
||||
|
||||
plugin.Metadata.ActionKeywords.Add(newActionKeyword);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
var milliseconds = Stopwatch.Debug($"|PluginsLoader.CSharpPlugins|Constructor init cost for {metadata.Name}", () =>
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(metadata.ExecuteFilePath);
|
||||
var types = assembly.GetTypes();
|
||||
@ -83,6 +82,7 @@ namespace Wox.Core.Plugin
|
||||
});
|
||||
metadata.InitTime += milliseconds;
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ namespace Wox.Core.Plugin
|
||||
RawQuery = rawQuery,
|
||||
ActionKeyword = actionKeyword,
|
||||
Search = search,
|
||||
|
||||
// Obsolete value initialisation
|
||||
ActionName = actionKeyword,
|
||||
ActionParameters = actionParameters
|
||||
|
@ -12,6 +12,7 @@ namespace Wox.Core.Resource
|
||||
public static class FontHelper
|
||||
{
|
||||
static FontWeightConverter fontWeightConverter = new FontWeightConverter();
|
||||
|
||||
public static FontWeight GetFontWeightFromInvariantStringOrNormal(string value)
|
||||
{
|
||||
if (value == null) return FontWeights.Normal;
|
||||
@ -27,6 +28,7 @@ namespace Wox.Core.Resource
|
||||
}
|
||||
|
||||
static FontStyleConverter fontStyleConverter = new FontStyleConverter();
|
||||
|
||||
public static FontStyle GetFontStyleFromInvariantStringOrNormal(string value)
|
||||
{
|
||||
if (value == null) return FontStyles.Normal;
|
||||
@ -42,6 +44,7 @@ namespace Wox.Core.Resource
|
||||
}
|
||||
|
||||
static FontStretchConverter fontStretchConverter = new FontStretchConverter();
|
||||
|
||||
public static FontStretch GetFontStretchFromInvariantStringOrNormal(string value)
|
||||
{
|
||||
if (value == null) return FontStretches.Normal;
|
||||
|
@ -19,6 +19,7 @@ namespace Wox.Core.Resource
|
||||
public class Internationalization
|
||||
{
|
||||
public Settings Settings { get; set; }
|
||||
|
||||
private const string Folder = "Languages";
|
||||
private const string DefaultFile = "en.xaml";
|
||||
private const string Extension = ".xaml";
|
||||
@ -29,6 +30,7 @@ namespace Wox.Core.Resource
|
||||
{
|
||||
AddPluginLanguageDirectories();
|
||||
LoadDefaultLanguage();
|
||||
|
||||
// we don't want to load /Languages/en.xaml twice
|
||||
// so add wox language directory after load plugin language files
|
||||
AddWoxLanguageDirectory();
|
||||
@ -97,6 +99,7 @@ namespace Wox.Core.Resource
|
||||
{
|
||||
LoadLanguage(language);
|
||||
}
|
||||
|
||||
UpdatePluginMetadataTranslations();
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ namespace Wox.Core.Resource
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user