using System; using Newtonsoft.Json; using System.Collections.Generic; namespace sharp.jsonrpc { public class Request { [JsonPropertyAttribute("sharp.jsonrpc")] public string jsonrpc { get; set; } = "2.0"; [JsonPropertyAttribute("id")] public String id { get; set; } = "0"; [JsonPropertyAttribute("method")] public String method { get; set; } [JsonPropertyAttribute("params")] public Dictionary args { get; set; } private Request(string method,Dictionary args){ this.id = Environment.TickCount.ToString(); this.method = method; this.args = args == null ? new Dictionary() : new Dictionary(args); } public static string Create(string method) { return Create(method, null); } public static string Create(string method,Dictionary args){ Request r = new Request(method,args); return JsonConvert.SerializeObject(r); } } }