C# Class MvcApi.Formatting.MediaTypeFormatter

Show file Open project: dax70/MvcApi Class Usage Examples

Public Methods

Method Description
CanWriteType ( Type type ) : bool
ExecuteFormat ( Type type, object returnValue, FormatterContext formatterContext ) : void
GetPerRequestFormatterInstance ( Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType ) : MediaTypeFormatter

Returns a specialized instance of the MediaTypeFormatter that can handle formatting a response for the given parameters. This method is called by DefaultContentNegotiator after a formatter has been selected through content negotiation.

The default implementation returns this instance. Derived classes can choose to return a new instance if they need to close over any of the parameters.

SelectCharacterEncoding ( HttpRequestMessage contentHeaders ) : Encoding

Determines the best Encoding amongst the supported encodings for reading or writing an HTTP entity body based on the provided contentHeaders.

Private Methods

Method Description
GetOrAddDelegatingType ( Type type ) : Type
GetResponseHeaders ( Type objectType, string mediaType, HttpResponseMessage responseMessage ) : string>>.IEnumerable
GetTypeRemappingConstructor ( Type type ) : ConstructorInfo
InitializeDefaultCollectionKeySize ( ) : int
MediaTypeFormatter ( ) : System
OnGetResponseHeaders ( Type objectType, string mediaType, HttpResponseMessage responseMessage ) : string>>.IEnumerable
TryGetDelegatingType ( Type interfaceType, Type &type ) : bool
TryGetDelegatingType1 ( Type interfaceType, Type &type ) : bool
TryGetDelegatingTypeForIEnumerableGenericOrSame ( Type &type ) : bool
TryGetDelegatingTypeForIQueryableGenericOrSame ( Type &type ) : bool
TryMatchMediaTypeMapping ( HttpRequestMessage request, MediaTypeFormatterMatch &mediaTypeMatch ) : bool
TryMatchMediaTypeMapping ( HttpResponseMessage response, MediaTypeFormatterMatch &mediaTypeMatch ) : bool

Method Details

CanWriteType() public abstract method

public abstract CanWriteType ( Type type ) : bool
type System.Type
return bool

ExecuteFormat() public abstract method

public abstract ExecuteFormat ( Type type, object returnValue, FormatterContext formatterContext ) : void
type Type
returnValue object
formatterContext FormatterContext
return void

GetPerRequestFormatterInstance() public method

Returns a specialized instance of the MediaTypeFormatter that can handle formatting a response for the given parameters. This method is called by DefaultContentNegotiator after a formatter has been selected through content negotiation.
The default implementation returns this instance. Derived classes can choose to return a new instance if they need to close over any of the parameters.
public GetPerRequestFormatterInstance ( Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType ) : MediaTypeFormatter
type Type The type being serialized.
request HttpRequestMessage The request.
mediaType MediaTypeHeaderValue The media type chosen for the serialization. Can be null.
return MediaTypeFormatter

SelectCharacterEncoding() public method

Determines the best Encoding amongst the supported encodings for reading or writing an HTTP entity body based on the provided contentHeaders.
public SelectCharacterEncoding ( HttpRequestMessage contentHeaders ) : Encoding
contentHeaders HttpRequestMessage The content headers provided as part of the request or response.
return Encoding