public static bool TryParseRequest( string packetString, Protocol formProtocol, Protocol expectedProtocol, out RequestPacket requestPacket, out object errorJObject) { requestPacket = null; errorJObject = null; try { switch (expectedProtocol) { #region system case Protocol.System_Version: requestPacket = JsonService.DeserializeFromNetwork <SystemVersionRequest>(packetString); return(true); case Protocol.Common_Cheat: requestPacket = JsonService.DeserializeFromNetwork <CommonCheatRequest>(packetString); return(true); case Protocol.Session_Info: requestPacket = JsonService.DeserializeFromNetwork <SessionInfoRequest>(packetString); return(true); #endregion default: throw new NotImplementedException($"protocol {expectedProtocol} has no matching request"); } } catch (Exception e) { errorJObject = ResultPacketBuilder.CreateErrorPacket(WebAPIErrorCode.InvalidPacket, e.Message, packetString); return(false); } }