Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to deserialise the data contained with a Rest Response
        /// </summary>
        /// <param name="response">The response containing the data to deserialise</param>
        /// <param name="deserializer"></param>
        public GetResult(IRestResponse response, IDeserializeJsonStrings deserializer) : base(response)
        {
            if (deserializer == null)
            {
                throw new ArgumentNullException("deserializer", "An instance of a deserializer needs to be provided");
            }

            DeserializeResponse(response, deserializer);
        }
Ejemplo n.º 2
0
 private void DeserializeResponse(IRestResponse response, IDeserializeJsonStrings deserializer)
 {
     try
     {
         Data = deserializer.Deserialize <T>(response.Content);
     }
     catch (Exception e)
     {
         StatusCode = HttpStatusCode.BadRequest;
         Body       = string.Format("The HTTP response could not be deserialized to the expected type. The following exception occurred: {0}", e);
     }
 }