Exemple #1
0
        public void V2SpecT020SerializeRequest()
        {
            var jsonSample        = EmbeddedResourceManager.GetString("Assets.v2_spec_02.0_req.json");
            var jsonRpcSerializer = new JsonRpcSerializer();

            var jsonRpcSubtractParameters = new Dictionary <string, object>
            {
                ["subtrahend"] = 23L,
                ["minuend"]    = 42L
            };

            var jsonRpcMessage = new JsonRpcRequest("subtract", 3L, jsonRpcSubtractParameters);
            var jsonResult     = jsonRpcSerializer.SerializeRequest(jsonRpcMessage);

            CompareJsonStrings(jsonSample, jsonResult);
        }
        public void SerializeRequestT021()
        {
            var jsont = EmbeddedResourceManager.GetString("Assets.v2_spec_02.1_req.json");
            var jrs   = new JsonRpcSerializer();

            var jrmp = new Dictionary <string, object>
            {
                ["subtrahend"] = 23L,
                ["minuend"]    = 42L
            };

            var jrm   = new JsonRpcRequest(4L, "subtract", jrmp);
            var jsonr = jrs.SerializeRequest(jrm);

            JsonRpcSerializerTests.CompareJsonStrings(jsont, jsonr);
        }
Exemple #3
0
        public void V1CoreSerializeRequestWhenParametersAreByName()
        {
            var jsonRpcSerializer = new JsonRpcSerializer
            {
                CompatibilityLevel = JsonRpcCompatibilityLevel.Level1
            };

            var parameters = new Dictionary <string, object>
            {
                ["p"] = 1L
            };

            var message = new JsonRpcRequest("m", parameters);

            Assert.Throws <JsonRpcException>(() =>
                                             jsonRpcSerializer.SerializeRequest(message));
        }
Exemple #4
0
        /// <summary>
        /// Сериализация пользовательских данных может спровоцировать исключение.
        /// </summary>
        /// <exception cref="VRpcSerializationException"/>
        /// <returns></returns>
        internal ArrayBufferWriter <byte> Serialize()
        {
            var buffer    = new ArrayBufferWriter <byte>();
            var toDispose = buffer;

            try
            {
                JsonRpcSerializer.SerializeRequest(buffer, MethodMeta.MethodFullName, Args, Uid);
                toDispose = null; // Предотвратить Dispose.
                return(buffer);
            }
            catch (Exception ex)
            {
                throw new VRpcSerializationException("Ошибка при сериализации пользовательских данных.", ex);
            }
            finally
            {
                toDispose?.Dispose();
            }
        }
Exemple #5
0
        private string CreateRequestJSON(string method_name, params object[] arguments)
        {
            var request = new JsonRpcRequest(0L, method_name, arguments);

            return(JSONRPCSerializer.SerializeRequest(request));
        }
 public object SerializeRequestB0I1P0()
 {
     return(_serializer.SerializeRequest(_reqsb0["req_b0i1p0"]));
 }
Exemple #7
0
 public object ParamsNoneSerializeRequest()
 {
     return(_serializer.SerializeRequest(_requests["request_params_none"]));
 }