C# Класс MvcApi.Formatting.DefaultContentNegotiator

Class that selects a MediaTypeFormatter for an HttpRequestMessage or HttpResponseMessage.
Наследование: IContentNegotiator
Показать файл Открыть проект

Открытые методы

Метод Описание
DefaultContentNegotiator ( ) : System
DefaultContentNegotiator ( bool excludeMatchOnTypeOnly ) : System

Initializes a new instance of the DefaultContentNegotiator with the given setting for excludeMatchOnTypeOnly.

Negotiate ( Type type, HttpRequestMessage request, IEnumerable formatters ) : ContentNegotiationResult

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.

Защищенные методы

Метод Описание
ComputeFormatterMatches ( Type type, HttpRequestMessage request, IEnumerable formatters ) : Collection

Determine how well each formatter matches by associating a MediaTypeFormatterMatchRanking value with the formatter. Then associate the quality of the match based on q-factors and other parameters. The result of this method is a collection of the matches found categorized and assigned a quality value.

MatchAcceptHeader ( IEnumerable sortedAcceptValues, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch

Match the request accept header field values against the formatter's registered supported media types.

MatchMediaTypeMapping ( HttpRequestMessage request, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch

Match a request against the MediaTypeMappings registered with the formatter.

MatchRequestMediaType ( HttpRequestMessage request, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch

Match any request media type (in case there is a request entity body) against the formatter's registered media types.

MatchType ( Type type, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch

Pick the first supported media type and indicate we've matched only on type If ExcludeMatchOnTypeOnly is true then we don't match on type only which means that we return null if we can't match on anything in the request. This is useful for generating 406 (Not Acceptable) status codes.

SelectResponseCharacterEncoding ( HttpRequestMessage request, MediaTypeFormatter formatter ) : Encoding

Determine the best character encoding for writing the response. First we look for accept-charset headers and if not found then we try to match any charset encoding in the request (in case of PUT, POST, etc.) If no encoding is found then we use the default for the formatter.

SelectResponseMediaTypeFormatter ( ICollection matches ) : MediaTypeFormatterMatch

Select the best match among the candidate matches found.

SortMediaTypeWithQualityHeaderValuesByQFactor ( ICollection headerValues ) : IEnumerable

Sort Accept header values and related header field values with similar syntax rules (if more than 1) in descending order based on q-factor.

SortStringWithQualityHeaderValuesByQFactor ( ICollection headerValues ) : IEnumerable

Sort Accept-Charset, Accept-Encoding, Accept-Language and related header field values with similar syntax rules (if more than 1) in descending order based on q-factor.

UpdateBestMatch ( MediaTypeFormatterMatch current, MediaTypeFormatterMatch potentialReplacement ) : MediaTypeFormatterMatch

Evaluates whether a match is better than the current match and if so returns the replacement; otherwise returns the current match.

Описание методов

ComputeFormatterMatches() защищенный Метод

Determine how well each formatter matches by associating a MediaTypeFormatterMatchRanking value with the formatter. Then associate the quality of the match based on q-factors and other parameters. The result of this method is a collection of the matches found categorized and assigned a quality value.
protected ComputeFormatterMatches ( Type type, HttpRequestMessage request, IEnumerable formatters ) : Collection
type System.Type The type to be serialized.
request MvcApi.Http.HttpRequestMessage The request.
formatters IEnumerable The set of objects from which to choose.
Результат Collection

DefaultContentNegotiator() публичный Метод

public DefaultContentNegotiator ( ) : System
Результат System

DefaultContentNegotiator() публичный Метод

Initializes a new instance of the DefaultContentNegotiator with the given setting for excludeMatchOnTypeOnly.
public DefaultContentNegotiator ( bool excludeMatchOnTypeOnly ) : System
excludeMatchOnTypeOnly bool /// If ExcludeMatchOnTypeOnly is true then we don't match on type only which means /// that we return null if we can't match on anything in the request. This is useful /// for generating 406 (Not Acceptable) status codes. ///
Результат System

MatchAcceptHeader() защищенный Метод

Match the request accept header field values against the formatter's registered supported media types.
protected MatchAcceptHeader ( IEnumerable sortedAcceptValues, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch
sortedAcceptValues IEnumerable The sorted accept header values to match.
formatter MediaTypeFormatter The formatter to match against.
Результат MediaTypeFormatterMatch

MatchMediaTypeMapping() защищенный Метод

Match a request against the MediaTypeMappings registered with the formatter.
protected MatchMediaTypeMapping ( HttpRequestMessage request, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch
request MvcApi.Http.HttpRequestMessage The request to match.
formatter MediaTypeFormatter The formatter to match against.
Результат MediaTypeFormatterMatch

MatchRequestMediaType() защищенный Метод

Match any request media type (in case there is a request entity body) against the formatter's registered media types.
protected MatchRequestMediaType ( HttpRequestMessage request, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch
request MvcApi.Http.HttpRequestMessage The request to match.
formatter MediaTypeFormatter The formatter to match against.
Результат MediaTypeFormatterMatch

MatchType() защищенный Метод

Pick the first supported media type and indicate we've matched only on type If ExcludeMatchOnTypeOnly is true then we don't match on type only which means that we return null if we can't match on anything in the request. This is useful for generating 406 (Not Acceptable) status codes.
protected MatchType ( Type type, MediaTypeFormatter formatter ) : MediaTypeFormatterMatch
type System.Type The type to be serialized.
formatter MediaTypeFormatter The formatter we are matching against.
Результат MediaTypeFormatterMatch

Negotiate() публичный Метод

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.
public Negotiate ( Type type, HttpRequestMessage request, IEnumerable formatters ) : ContentNegotiationResult
type System.Type The type to be serialized.
request MvcApi.Http.HttpRequestMessage The request.
formatters IEnumerable The set of objects from which to choose.
Результат ContentNegotiationResult

SelectResponseCharacterEncoding() защищенный Метод

Determine the best character encoding for writing the response. First we look for accept-charset headers and if not found then we try to match any charset encoding in the request (in case of PUT, POST, etc.) If no encoding is found then we use the default for the formatter.
protected SelectResponseCharacterEncoding ( HttpRequestMessage request, MediaTypeFormatter formatter ) : Encoding
request MvcApi.Http.HttpRequestMessage
formatter MediaTypeFormatter
Результат System.Text.Encoding

SelectResponseMediaTypeFormatter() защищенный Метод

Select the best match among the candidate matches found.
protected SelectResponseMediaTypeFormatter ( ICollection matches ) : MediaTypeFormatterMatch
matches ICollection The collection of matches.
Результат MediaTypeFormatterMatch

SortMediaTypeWithQualityHeaderValuesByQFactor() защищенный Метод

Sort Accept header values and related header field values with similar syntax rules (if more than 1) in descending order based on q-factor.
protected SortMediaTypeWithQualityHeaderValuesByQFactor ( ICollection headerValues ) : IEnumerable
headerValues ICollection The header values to sort.
Результат IEnumerable

SortStringWithQualityHeaderValuesByQFactor() защищенный Метод

Sort Accept-Charset, Accept-Encoding, Accept-Language and related header field values with similar syntax rules (if more than 1) in descending order based on q-factor.
protected SortStringWithQualityHeaderValuesByQFactor ( ICollection headerValues ) : IEnumerable
headerValues ICollection The header values to sort.
Результат IEnumerable

UpdateBestMatch() защищенный Метод

Evaluates whether a match is better than the current match and if so returns the replacement; otherwise returns the current match.
protected UpdateBestMatch ( MediaTypeFormatterMatch current, MediaTypeFormatterMatch potentialReplacement ) : MediaTypeFormatterMatch
current MediaTypeFormatterMatch
potentialReplacement MediaTypeFormatterMatch
Результат MediaTypeFormatterMatch