Example #1
0
        protected override Task <Stream> RequestAsync(JsonRPCRequestModel request, CancellationToken token = default)
        {
            var byteInfo = Encoding.UTF8.GetBytes(request.Parameters[0] as string ?? string.Empty);

            var resultStream = new MemoryStream(byteInfo);

            return(Task.FromResult((Stream)resultStream));
        }
Example #2
0
        public List <Result> Query(Query query)
        {
            string output = ExecuteQuery(query);

            if (!string.IsNullOrEmpty(output))
            {
                try
                {
                    List <Result> results = new List <Result>();

                    JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject <JsonRPCQueryResponseModel>(output);
                    if (queryResponseModel.Result == null)
                    {
                        return(null);
                    }

                    foreach (JsonRPCResult result in queryResponseModel.Result)
                    {
                        JsonRPCResult result1 = result;
                        result.Action = (c) =>
                        {
                            if (!string.IsNullOrEmpty(result1.JsonRPCAction.Method))
                            {
                                if (result1.JsonRPCAction.Method.StartsWith("Wox."))
                                {
                                    ExecuteWoxAPI(result1.JsonRPCAction.Method.Substring(4), result1.JsonRPCAction.Parameters);
                                }
                                else
                                {
                                    ThreadPool.QueueUserWorkItem(state =>
                                    {
                                        string actionReponse = ExecuteAction(result1.JsonRPCAction);
                                        JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject <JsonRPCRequestModel>(actionReponse);
                                        if (jsonRpcRequestModel != null &&
                                            !string.IsNullOrEmpty(jsonRpcRequestModel.Method) &&
                                            jsonRpcRequestModel.Method.StartsWith("Wox."))
                                        {
                                            ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4), jsonRpcRequestModel.Parameters);
                                        }
                                    });
                                }
                            }
                            return(!result1.JsonRPCAction.DontHideAfterAction);
                        };
                        results.Add(result);
                    }
                    return(results);
                }
                catch (Exception e)
                {
                    ErrorReporting.TryShowErrorMessageBox(e.Message, e);
                    Log.Error(e.Message);
                }
            }
            return(null);
        }
Example #3
0
 protected override string Request(JsonRPCRequestModel rpcRequest, CancellationToken token = default)
 {
     throw new System.NotImplementedException();
 }
Example #4
0
 protected override string ExecuteAction(JsonRPCRequestModel rpcRequest)
 {
     startInfo.FileName  = Path.Combine(woxDirectory, "PythonHome\\pythonw.exe");
     startInfo.Arguments = string.Format("-B \"{0}\" \"{1}\"", context.CurrentPluginMetadata.ExecuteFilePath, rpcRequest);
     return(Execute(startInfo));
 }
Example #5
0
 protected abstract string ExecuteAction(JsonRPCRequestModel rpcRequest);