Table of Contents

Class ODataMediaTypeFormatter

Namespace
System.Web.Http.OData.Formatter
Assembly
System.Web.Http.OData.dll

System.Net.Http.Formatting.MediaTypeFormatter class to handle OData.

public class ODataMediaTypeFormatter : MediaTypeFormatter
Inheritance
ODataMediaTypeFormatter

Constructors

ODataMediaTypeFormatter(IEnumerable<ODataPayloadKind>)

Initializes a new instance of the ODataMediaTypeFormatter class.

public ODataMediaTypeFormatter(IEnumerable<ODataPayloadKind> payloadKinds)

Parameters

payloadKinds IEnumerable<ODataPayloadKind>

The kind of payloads this formatter supports.

ODataMediaTypeFormatter(ODataDeserializerProvider, ODataSerializerProvider, IEnumerable<ODataPayloadKind>)

Initializes a new instance of the ODataMediaTypeFormatter class.

public ODataMediaTypeFormatter(ODataDeserializerProvider deserializerProvider, ODataSerializerProvider serializerProvider, IEnumerable<ODataPayloadKind> payloadKinds)

Parameters

deserializerProvider ODataDeserializerProvider

The ODataDeserializerProvider to use.

serializerProvider ODataSerializerProvider

The ODataSerializerProvider to use.

payloadKinds IEnumerable<ODataPayloadKind>

The kind of payloads this formatter supports.

Properties

DeserializerProvider

Gets the ODataDeserializerProvider that will be used by this formatter instance.

public ODataDeserializerProvider DeserializerProvider { get; }

Property Value

ODataDeserializerProvider

MessageReaderQuotas

Gets the Microsoft.Data.OData.ODataMessageQuotas that this formatter uses on the read side.

public ODataMessageQuotas MessageReaderQuotas { get; }

Property Value

ODataMessageQuotas

MessageReaderSettings

Gets the Microsoft.Data.OData.ODataMessageReaderSettings to be used while reading requests.

public ODataMessageReaderSettings MessageReaderSettings { get; }

Property Value

ODataMessageReaderSettings

MessageWriterQuotas

Gets the Microsoft.Data.OData.ODataMessageQuotas that this formatter uses on the write side.

public ODataMessageQuotas MessageWriterQuotas { get; }

Property Value

ODataMessageQuotas

MessageWriterSettings

Gets the Microsoft.Data.OData.ODataMessageWriterSettings to be used while writing responses.

public ODataMessageWriterSettings MessageWriterSettings { get; }

Property Value

ODataMessageWriterSettings

SerializerProvider

Gets the ODataSerializerProvider that will be used by this formatter instance.

public ODataSerializerProvider SerializerProvider { get; }

Property Value

ODataSerializerProvider

Methods

CanReadType(Type)

public override bool CanReadType(Type type)

Parameters

type Type

Returns

bool

CanWriteType(Type)

public override bool CanWriteType(Type type)

Parameters

type Type

Returns

bool

GetPerRequestFormatterInstance(Type, HttpRequestMessage, MediaTypeHeaderValue)

public override MediaTypeFormatter GetPerRequestFormatterInstance(Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType)

Parameters

type Type
request HttpRequestMessage
mediaType MediaTypeHeaderValue

Returns

MediaTypeFormatter

ReadFromStreamAsync(Type, Stream, HttpContent, IFormatterLogger)

public override Task<object> ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)

Parameters

type Type
readStream Stream
content HttpContent
formatterLogger IFormatterLogger

Returns

Task<object>

SetDefaultContentHeaders(Type, HttpContentHeaders, MediaTypeHeaderValue)

public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType)

Parameters

type Type
headers HttpContentHeaders
mediaType MediaTypeHeaderValue

WriteToStreamAsync(Type, object, Stream, HttpContent, TransportContext, CancellationToken)

public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)

Parameters

type Type
value object
writeStream Stream
content HttpContent
transportContext TransportContext
cancellationToken CancellationToken

Returns

Task