DefaultContentNegotiator
The default implementation of IContentNegotiator, which is used to select a MediaTypeFormatter for an HttpRequestMessage or HttpResponseMessage.
If true, exclude formatters that match only on the object type; otherwise, false.
public DefaultContentNegotiator()
Initializes a new instance of the DefaultContentNegotiator class.
Initializes a new instance of the DefaultContentNegotiator class.
protected virtual Collection<MediaTypeFormatterMatch> ComputeFormatterMatches(Type type, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)
Determines how well each formatter matches an HTTP request.
protected virtual MediaTypeFormatterMatch MatchAcceptHeader(IEnumerable<MediaTypeWithQualityHeaderValue> sortedAcceptValues, MediaTypeFormatter formatter)
Matches a set of Accept header fields against the media types that a formatter supports.
protected virtual MediaTypeFormatterMatch MatchMediaTypeMapping(HttpRequestMessage request, MediaTypeFormatter formatter)
Matches a request against the MediaTypeMapping objects in a media-type formatter.
protected virtual MediaTypeFormatterMatch MatchRequestMediaType(HttpRequestMessage request, MediaTypeFormatter formatter)
Match the content type of a request against the media types that a formatter supports.
Selects the first supported media type of a formatter.
public virtual ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)
Performs content negotiating by selecting the most appropriate MediaTypeFormatter out of the passed in formatters for the given request that can serialize an object of the given type.
protected virtual Encoding SelectResponseCharacterEncoding(HttpRequestMessage request, MediaTypeFormatter formatter)
Determines the best character encoding for writing the response.
protected virtual MediaTypeFormatterMatch SelectResponseMediaTypeFormatter(ICollection<MediaTypeFormatterMatch> matches)
Selects the best match among the candidate matches found.
protected virtual IEnumerable<MediaTypeWithQualityHeaderValue> SortMediaTypeWithQualityHeaderValuesByQFactor(ICollection<MediaTypeWithQualityHeaderValue> headerValues)
Sorts Accept header values in descending order of q factor.
protected virtual IEnumerable<StringWithQualityHeaderValue> SortStringWithQualityHeaderValuesByQFactor(ICollection<StringWithQualityHeaderValue> headerValues)
Sorts a list of Accept-Charset, Accept-Encoding, Accept-Language or related header values in descending order or q factor.
protected virtual MediaTypeFormatterMatch UpdateBestMatch(MediaTypeFormatterMatch current, MediaTypeFormatterMatch potentialReplacement)
Evaluates whether a match is better than the current match.