public static async Task <ISteamWebResponse <T> > HttpResponseMessageToISteamWebResponse <T>(HttpResponseMessage httpResponseMessage) { HttpContentHeaders headers = httpResponseMessage.Content?.Headers; var steamWebResponse = new SteamWebResponse <T>() { ContentLength = headers?.ContentLength, ContentType = headers?.ContentType?.MediaType, ContentTypeCharSet = headers?.ContentType?.CharSet, Expires = headers?.Expires, LastModified = headers?.LastModified }; if (httpResponseMessage.StatusCode != HttpStatusCode.NoContent && httpResponseMessage.Content != null) { steamWebResponse.Data = JsonConvert.DeserializeObject <T>(HelperClass.CleanupResponseString(await httpResponseMessage.Content.ReadAsStringAsync())); } return(steamWebResponse); }
private static SteamWebResponse <TDestination> ConstructSteamWebResponse <TSource, TDestination>(ISteamWebResponse <TSource> response) { if (response == null) { return(null); } var newResponse = new SteamWebResponse <TDestination>(); newResponse.ContentLength = response.ContentLength; newResponse.ContentType = response.ContentType; newResponse.ContentTypeCharSet = response.ContentTypeCharSet; newResponse.Expires = response.Expires; newResponse.LastModified = response.LastModified; if (response.Data != null) { newResponse.Data = Mapper.Map <TSource, TDestination>(response.Data); } return(newResponse); }