Exemple #1
0
        public virtual JsonRpcResponse Execute()
        {
            JsonRpcResponse response = new JsonRpcResponse();
            // get the method from RpcMethods
            MethodInfo mi = RpcMethods.FirstOrDefault(m => m.Name.Equals(Method, StringComparison.InvariantCultureIgnoreCase));

            // if its not there get it from all methods
            if (mi == null)
            {
                mi = AllMethods.FirstOrDefault(m => m.Name.Equals(Method, StringComparison.InvariantCultureIgnoreCase));
            }
            // if its not there set error in the response
            if (mi == null)
            {
                response = GetErrorResponse(JsonRpcFaultCodes.MethodNotFound);
            }
            else
            {
                ExecutionRequest execRequest = ExecutionRequest.Create(Incubator, mi, GetInputParameters(mi));
                ValidationResult validation  = execRequest.Validate();
                if (validation.Success)
                {
                    if (execRequest.ExecuteWithoutValidation())
                    {
                        response.Result = execRequest.Result;
                    }
                    else
                    {
                        response = GetErrorResponse(JsonRpcFaultCodes.InternalError);
                    }
                }
                else
                {
                    response = GetErrorResponse(JsonRpcFaultCodes.InvalidRequest);
                }
            }

            return(response);
        }
 public void AddResponse(JsonRpcResponse response)
 {
     _responses.Add(response);
 }