public static bool TryParse <T>(Session session, out SvData <T> result) { try { result = Parse <T>(session); } catch (Exception ex) { Debug.WriteLine(ex); result = null; } return(result != null); }
public static SvData <T> Parse <T>(Session session) { var json = SvData.JsonParse(session.Response.BodyAsString); if (json == null) { return(null); } var bytes = Encoding.UTF8.GetBytes(json); var serializer = new DataContractJsonSerializer(typeof(SvDataBase <T>)); using (var stream = new MemoryStream(bytes)) { var rawResult = serializer.ReadObject(stream) as SvDataBase <T>; var result = new SvData <T>(rawResult, session.Request.BodyAsString); return(result); } }