MediaTypeFormatter.GetPerRequestFormatterInstance Method
Returns a specialized instance of the MediaTypeFormatter that can format a response for the given parameters.
Namespace: System.Net.Http.Formatting
Assembly: System.Net.Http.Formatting (in System.Net.Http.Formatting.dll)
Syntax
'Declaration
Public Overridable Function GetPerRequestFormatterInstance ( _
type As Type, _
request As HttpRequestMessage, _
mediaType As MediaTypeHeaderValue _
) As MediaTypeFormatter
'Usage
Dim instance As MediaTypeFormatter
Dim type As Type
Dim request As HttpRequestMessage
Dim mediaType As MediaTypeHeaderValue
Dim returnValue As MediaTypeFormatter
returnValue = instance.GetPerRequestFormatterInstance(type, _
request, mediaType)
public virtual MediaTypeFormatter GetPerRequestFormatterInstance(
Type type,
HttpRequestMessage request,
MediaTypeHeaderValue mediaType
)
public:
virtual MediaTypeFormatter^ GetPerRequestFormatterInstance(
Type^ type,
HttpRequestMessage^ request,
MediaTypeHeaderValue^ mediaType
)
abstract GetPerRequestFormatterInstance :
type:Type *
request:HttpRequestMessage *
mediaType:MediaTypeHeaderValue -> MediaTypeFormatter
override GetPerRequestFormatterInstance :
type:Type *
request:HttpRequestMessage *
mediaType:MediaTypeHeaderValue -> MediaTypeFormatter
public function GetPerRequestFormatterInstance(
type : Type,
request : HttpRequestMessage,
mediaType : MediaTypeHeaderValue
) : MediaTypeFormatter
Parameters
type
Type: System.TypeThe type to format.
request
Type: HttpRequestMessageThe request.
mediaType
Type: MediaTypeHeaderValueThe media type.
Return Value
Type: System.Net.Http.Formatting.MediaTypeFormatter
Returns MediaTypeFormatter.
Remarks
The DefaultContentNegotiator calls this method after it selects a formatter. The default implementation returns this instance. A derived class can return a new instance if it needs to initialize the formatter or use a specialized version.