MvcApi.Formatting.MediaTypeFormatter.GetPerRequestFormatterInstance C# (CSharp) Method

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
        public virtual MediaTypeFormatter GetPerRequestFormatterInstance(Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType)
        {
            if (type == null)
            {
                throw Error.ArgumentNull("type");
            }
            if (request == null)
            {
                throw Error.ArgumentNull("request");
            }

            return this;
        }