Exemple #1
0
        public object Clone()
        {
            JsonRpcNotification clone = new JsonRpcNotification();

            clone.CopyProperties(this);
            return(clone);
        }
Exemple #2
0
        public static JsonRpcNotification Create <T>(Incubator serviceProvider, string methodName, params object[] parameters)
        {
            JsonRpcNotification result = Create <T>(methodName, parameters);

            result.Incubator = serviceProvider;
            return(result);
        }
Exemple #3
0
        protected static internal IJsonRpcRequest ParseRequest(JToken parsed, string json)
        {
            bool isNotification            = parsed["id"] == null && parsed["Id"] == null;
            JsonRpcNotification rpcMessage = isNotification ? json.FromJson <JsonRpcNotification>() : json.FromJson <JsonRpcRequest>();

            SetParams(parsed, rpcMessage);
            return(rpcMessage);
        }
Exemple #4
0
        public static JsonRpcRequest Create(Incubator incubator, object id, MethodInfo method, params object[] parameters)
        {
            JsonRpcNotification notification = JsonRpcNotification.Create(incubator, method, parameters);
            JsonRpcRequest      request      = notification.CopyAs <JsonRpcRequest>();

            request.Incubator = incubator;
            request.Id        = id;
            return(request);
        }
Exemple #5
0
        public static JsonRpcNotification Create(Incubator serviceProvider, MethodInfo method, params object[] parameters)
        {
            JsonRpcNotification result = new JsonRpcNotification();

            result.Incubator             = serviceProvider;
            result.Method                = method.Name;
            result.RpcParams.By.Position = parameters;
            result.Params                = JToken.Parse(parameters.ToJson());
            return(result);
        }
Exemple #6
0
        protected static void SetParams(JToken parsed, JsonRpcNotification notification)
        {
            JToken parms = parsed["params"];

            if (parms != null)
            {
                if (parms.Is <JObject>())
                {
                    notification.RpcParams.By = new JsonRpcParameters.Structure {
                        Name = parms
                    };
                }
                else if (parms.Is <JArray>())
                {
                    notification.RpcParams.By = new JsonRpcParameters.Structure {
                        Position = parms.ToString().FromJson <object[]>()
                    };
                }
            }
        }