C# 클래스 MvcApi.Formatting.DefaultContentNegotiator

Class that selects a MediaTypeFormatter for an HttpRequestMessage or HttpResponseMessage.
상속: IContentNegotiator
파일 보기 프로젝트 열기: dax70/MvcApi

공개 메소드들

메소드 설명
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