public T GetRPCTypedResult <T>(RPCConnection rpc, string commandName, object[] _params)
        {
            var result = rpc.RunCommand(commandName, _params);

            if (string.IsNullOrEmpty(result))
            {
                return(default(T));
            }
            if (string.IsNullOrEmpty(result))
            {
                throw new Exception("Result is null");
            }
            if (typeof(T) == typeof(string) ||
                typeof(T) == typeof(int) ||
                typeof(T) == typeof(long) ||
                typeof(T) == typeof(double) ||
                typeof(T) == typeof(bool))
            {
                return(JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(result.Replace("\"", ""))));
            }
            else
            {
                return(JsonConvert.DeserializeObject <T>(result));
            }
        }
Ejemplo n.º 2
0
        public T GetRPCTypedResult <T>(RPCConnection rpc, ZendRPCCommand commandName, object[] _params)
        {
            var result = rpc.RunCommand(commandName, _params);

            if (typeof(T) == typeof(string) ||
                typeof(T) == typeof(int) ||
                typeof(T) == typeof(long) ||
                typeof(T) == typeof(double) ||
                typeof(T) == typeof(bool))
            {
                return(JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(result.Replace("\"", ""))));
            }

            return(JsonConvert.DeserializeObject <T>(result));
        }
        public T GetRPCTypedResult <T>(RPCConnection rpc, List <RPCData> data)
        {
            var result = rpc.RunCommand(data);

            return(string.IsNullOrEmpty(result) ? default(T) : JsonConvert.DeserializeObject <T>(result));
        }
Ejemplo n.º 4
0
        public T GetRPCTypedResult <T>(RPCConnection rpc, List <RPCData> data)
        {
            var result = rpc.RunCommand(data);

            return(JsonConvert.DeserializeObject <T>(result));
        }