Exemplo n.º 1
0
        /// <summary>
        /// Deserializes the JSON key-gen response.
        /// </summary>
        /// <param name="json">The json string to deserialize from.</param>
        /// <returns></returns>
        public static KeygenResponse FromJson(string json)
        {
            var map = JsonSerializer.DeserializeString(json) as Hashtable;

            // Check for error.
            ErrorEvent.ThrowIfError(map);

            var response = new KeygenResponse();

            if (map.ContainsKey("req"))
            {
                response.RequestId = (long)map["req"];
            }
            if (map.ContainsKey("key"))
            {
                response.Key = (string)map["key"];
            }
            if (map.ContainsKey("channel"))
            {
                response.Channel = (string)map["channel"];
            }
            if (map.ContainsKey("status"))
            {
                response.Status = Convert.ToInt32(map["status"].ToString());
            }

            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserializes the JSON key-gen response.
        /// </summary>
        /// <param name="json">The json string to deserialize from.</param>
        /// <returns></returns>
        public static KeygenResponse FromJson(string json)
        {
            var map      = JsonSerializer.DeserializeString(json) as Hashtable;
            var response = new KeygenResponse();

            response.Key     = (string)map["key"];
            response.Channel = (string)map["channel"];
            response.Status  = Convert.ToInt32(map["status"].ToString());

            return(response);
        }