ContextMenu 2: Extract DeserializedResult #1366

This commit is contained in:
Michael Eichhorn
2017-04-11 14:31:50 +01:00
committed by bao-qian
parent de12208d4a
commit 5198f70ebf

View File

@@ -33,10 +33,21 @@ namespace Wox.Core.Plugin
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
string output = ExecuteQuery(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<Result> DeserializedResult(string output)
{
if (!String.IsNullOrEmpty(output)) if (!String.IsNullOrEmpty(output))
{ {
try
{
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject<JsonRPCQueryResponseModel>(output); JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject<JsonRPCQueryResponseModel>(output);
@@ -72,15 +83,11 @@ namespace Wox.Core.Plugin
results.Add(result); results.Add(result);
} }
return results; return results;
}
catch (Exception e)
{
Log.Exception($"|JsonRPCPlugin.Query|Exception when query <{query}>", e);
}
} }
return null; return null;
} }
private void ExecuteWoxAPI(string method, object[] parameters) private void ExecuteWoxAPI(string method, object[] parameters)
{ {
MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method); MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);