IContentNegotiator.Negotiate(Type, HttpRequestMessage, IEnumerable<MediaTypeFormatter>) IContentNegotiator.Negotiate(Type, HttpRequestMessage, IEnumerable<MediaTypeFormatter>) Method

Definition

Performs content negotiating by selecting the most appropriate System.Net.Http.Formatting.MediaTypeFormatter out of the passed in formatters for the given request that can serialize an object of the given type.

public System.Net.Http.Formatting.ContentNegotiationResult Negotiate (Type type, System.Net.Http.HttpRequestMessage request, System.Collections.Generic.IEnumerable<System.Net.Http.Formatting.MediaTypeFormatter> formatters);
abstract member Negotiate : Type * System.Net.Http.HttpRequestMessage * seq<System.Net.Http.Formatting.MediaTypeFormatter> -> System.Net.Http.Formatting.ContentNegotiationResult

Parameters

type
Type Type

The type to be serialized.

request
HttpRequestMessage HttpRequestMessage

Request message, which contains the header values used to perform negotiation.

formatters
IEnumerable<System.Net.Http.Formatting.MediaTypeFormatter>

The set of System.Net.Http.Formatting.MediaTypeFormatter objects from which to choose.

Returns

The result of the negotiation containing the most appropriate System.Net.Http.Formatting.MediaTypeFormatter instance, or null if there is no appropriate formatter.

Remarks

Implementations of this method should call System.Net.Http.Formatting.MediaTypeFormatter.GetPerRequestFormatterInstance(System.Type,System.Net.Http.HttpRequestMessage,System.Net.Http.Headers.MediaTypeHeaderValue) on the selected System.Net.Http.Formatting.MediaTypeFormatter and return the result of that method.

Applies to