コード例 #1
0
        private static JsonRpcResponce GetResponce(string json, out bool isNotification)
        {
            isNotification = false;

            if (JsonRpcParser.ValidateJson(json) == false)
            {
                return(SendError(-32700, "Parse error"));
            }

            Type paramsType = GetRequestParamsType(json);

            if (paramsType == null)
            {
                return(SendError(-32600, "Invalid Request"));
            }

            if (paramsType == typeof(object[]))
            {
                return(HandleRequest(json, out isNotification));
            }
            else
            {
                return(HandleNamedRequest(json, out isNotification));
            }
        }
コード例 #2
0
        private static Type GetRequestParamsType(string json)
        {
            Type type;

            if (JsonRpcParser.TryParseRequest <object[]>(json, out type) == true)
            {
                return(type);
            }
            else if (JsonRpcParser.TryParseRequest <Dictionary <string, object> >(json, out type) == true)
            {
                return(type);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        private static JsonRpcResponce HandleNamedRequest(string json, out bool isNotification)
        {
            isNotification = false;

            JsonRpcRequest <Dictionary <string, object> > request = JsonRpcParser.ParseRequest <Dictionary <string, object> >(json);

            if (request.id == null)
            {
                isNotification = true;
            }

            MethodInfo method = ValidateMethod(request.method);

            if (method == null)
            {
                return(SendError(-32601, "Method not found", request.id));
            }

            return(ExecuteNamedMethod(method, request.@params, request.id));
        }