/// <summary> /// Gets the deserialized representation of the XML in the response body. /// </summary> /// <typeparam name="TModel">The type that the XML response body should be deserialized to.</typeparam> /// <param name="bodyWrapper">An instance of the <see cref="BrowserResponseBodyWrapper"/> that the extension should be invoked on.</param> /// <value>A <typeparamref name="TModel"/> instance representation of the HTTP response body.</value> public static TModel DeserializeXml <TModel>(this BrowserResponseBodyWrapper bodyWrapper) { var serializer = new XmlSerializer(typeof(TModel)); return((TModel)serializer.Deserialize(bodyWrapper.AsStream())); }
/// <summary> /// Gets the deserialized representation of the response body using the specified body deserializer. /// </summary> /// <typeparam name="TModel">The type that the response body should be deserialized to.</typeparam> /// <param name="bodyWrapper">An instance of the <see cref="BrowserResponseBodyWrapper"/> that the extension should be invoked on.</param> /// <param name="bodyDeserializer">An instance of the <see cref="IBodyDeserializer"/> that should be used to deserialize the response body.</param> /// <value>A <typeparamref name="TModel"/> instance representation of the HTTP response body.</value> public static TModel Deserialize <TModel>(this BrowserResponseBodyWrapper bodyWrapper, IBodyDeserializer bodyDeserializer) { var bindingContext = new BindingContext { DestinationType = typeof(TModel) }; return((TModel)bodyDeserializer.Deserialize(bodyWrapper.ContentType, bodyWrapper.AsStream(), bindingContext)); }