/// <summary> /// Convert a JSON String to a Request Type. /// </summary> /// <param name="JSONString">JSON formatted string.</param> /// <returns></returns> public static Request ToRequest(string JSONString) { try { JSONRequest request = JsonConvert.DeserializeObject <JSONRequest>(JSONString); return(new Request(request.request, request.pid, request.parameters)); } catch (Exception ex) { //FileLogger.Instance.LogException(ex); return(null); } }
/// <summary> /// Serialize a Request type to a JSON String. /// </summary> /// <param name="request">Request object to serialize.</param> /// <returns></returns> public static string ToRequestString(Request request) { try { JSONRequest JRequest = new JSONRequest(); JRequest.parameters = request.Parameters; JRequest.pid = request.Pid; JRequest.request = request.MethodName; return(JsonConvert.SerializeObject(JRequest)); } catch (Exception ex) { //FileLogger.Instance.LogException(ex); return(null); } }