public bool CanFormatResponse(ContentType acceptHeaderElement, bool matchCharset, out ContentType contentType)
{
if (acceptHeaderElement == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("acceptHeaderElement");
}
// Scrub the content type so that it is only mediaType and the charset
string charset = acceptHeaderElement.CharSet;
contentType = new ContentType(acceptHeaderElement.MediaType);
contentType.CharSet = this.DefaultContentType.CharSet;
string contentTypeStr = contentType.ToString();
if (matchCharset &&
!string.IsNullOrEmpty(charset) &&
!string.Equals(charset, this.DefaultContentType.CharSet, StringComparison.OrdinalIgnoreCase))
{
return false;
}
if (this.contentTypeMapper != null &&
this.contentTypeMapper.GetMessageFormatForContentType(contentType.MediaType) == this.ContentFormat)
{
return true;
}
if (this.Encoder.IsContentTypeSupported(contentTypeStr) &&
(charset == null || contentType.CharSet == this.DefaultContentType.CharSet))
{
return true;
}
contentType = null;
return false;
}