Share via


IContentNegotiator.Negotiate Method

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.

Namespace:  System.Net.Http.Formatting
Assembly:  System.Net.Http.Formatting (in System.Net.Http.Formatting.dll)

Syntax

'Declaration
Function Negotiate ( _
    type As Type, _
    request As HttpRequestMessage, _
    formatters As IEnumerable(Of MediaTypeFormatter) _
) As ContentNegotiationResult
'Usage
Dim instance As IContentNegotiator 
Dim type As Type 
Dim request As HttpRequestMessage 
Dim formatters As IEnumerable(Of MediaTypeFormatter)
Dim returnValue As ContentNegotiationResult 

returnValue = instance.Negotiate(type, _
    request, formatters)
ContentNegotiationResult Negotiate(
    Type type,
    HttpRequestMessage request,
    IEnumerable<MediaTypeFormatter> formatters
)
ContentNegotiationResult^ Negotiate(
    Type^ type, 
    HttpRequestMessage^ request, 
    IEnumerable<MediaTypeFormatter^>^ formatters
)
abstract Negotiate : 
        type:Type * 
        request:HttpRequestMessage * 
        formatters:IEnumerable<MediaTypeFormatter> -> ContentNegotiationResult
function Negotiate(
    type : Type, 
    request : HttpRequestMessage, 
    formatters : IEnumerable<MediaTypeFormatter>
) : ContentNegotiationResult

Parameters

  • request
    Type: HttpRequestMessage

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

Return Value

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

Remarks

Implementations of this method should call <see cref="M:System.Net.Http.Formatting.MediaTypeFormatter.GetPerRequestFormatterInstance(System.Type,System.Net.Http.HttpRequestMessage,System.Net.Http.Headers.MediaTypeHeaderValue)" /> on the selected MediaTypeFormatter and return the result of that method.

See Also

Reference

IContentNegotiator Interface

System.Net.Http.Formatting Namespace