/// <inheritdoc /> public bool CanConvertFromHttpContent(Type typeToConvertTo, HttpContent httpContent) { if (!typeToConvertTo.GetTypeInfo().IsClass && !typeToConvertTo.GetTypeInfo().IsInterface) { return false; } var httpBehaviour = HttpBehaviour.Current; return !httpBehaviour.ValidateResponseContentType || SupportedContentTypes.Contains(httpContent.GetContentType()); }
/// <inheritdoc /> public bool CanConvertFromHttpContent(Type typeToConvertTo, HttpContent httpContent) { // Check if the return-type can be assigned if (typeToConvertTo == typeof (object) || !typeToConvertTo.IsAssignableFrom(typeof (IEnumerable<KeyValuePair<string, string>>))) { return false; } return httpContent.GetContentType() == MediaTypes.WwwFormUrlEncoded.EnumValueOf(); }
/// <summary> /// This checks if the HttpContent can be converted to a Bitmap and is assignable to the specified Type /// </summary> /// <param name="typeToConvertTo">This should be something we can assign Bitmap to</param> /// <param name="httpContent">HttpContent to process</param> /// <returns>true if it can convert</returns> public bool CanConvertFromHttpContent(Type typeToConvertTo, HttpContent httpContent) { if (typeToConvertTo == typeof (object) || !typeToConvertTo.IsAssignableFrom(typeof (BitmapImage))) { return false; } var httpBehaviour = HttpBehaviour.Current; var configuration = httpBehaviour.GetConfig<BitmapSourceConfiguration>(); return !httpBehaviour.ValidateResponseContentType || configuration.SupportedContentTypes.Contains(httpContent.GetContentType()); }
/// <inheritdoc /> public bool CanConvertFromHttpContent(Type typeToConvertTo, HttpContent httpContent) { if (typeToConvertTo != typeof (string)) { return false; } var httpBehaviour = HttpBehaviour.Current; var configuration = httpBehaviour.GetConfig<StringConfiguration>(); // Set ValidateResponseContentType to false to "catch" all return !httpBehaviour.ValidateResponseContentType || configuration.SupportedContentTypes.Contains(httpContent.GetContentType()); }