From 5198f70ebf5f6cf994585c78220b0517c393dc03 Mon Sep 17 00:00:00 2001 From: Michael Eichhorn Date: Tue, 11 Apr 2017 14:31:50 +0100 Subject: [PATCH] ContextMenu 2: Extract DeserializedResult #1366 --- Wox.Core/Plugin/JsonRPCPlugin.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Wox.Core/Plugin/JsonRPCPlugin.cs b/Wox.Core/Plugin/JsonRPCPlugin.cs index 2855fa1d1c..8ba7db5c1e 100644 --- a/Wox.Core/Plugin/JsonRPCPlugin.cs +++ b/Wox.Core/Plugin/JsonRPCPlugin.cs @@ -33,10 +33,21 @@ namespace Wox.Core.Plugin public List Query(Query query) { string output = ExecuteQuery(query); + try + { + return DeserializedResult(output); + } + catch (Exception e) + { + Log.Exception($"|JsonRPCPlugin.Query|Exception when query <{query}>", e); + return null; + } + } + + public List DeserializedResult(string output) + { if (!String.IsNullOrEmpty(output)) { - try - { List results = new List(); JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject(output); @@ -72,15 +83,11 @@ namespace Wox.Core.Plugin results.Add(result); } return results; - } - catch (Exception e) - { - Log.Exception($"|JsonRPCPlugin.Query|Exception when query <{query}>", e); - } } return null; } + private void ExecuteWoxAPI(string method, object[] parameters) { MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);