Language

MediaTypeFormatter Class

 

Base class to handle serializing and deserializing strongly-typed objects using ObjectContent.

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

Inheritance Hierarchy

System.Object   System.Net.Http.Formatting.MediaTypeFormatter     System.Net.Http.Formatting.BaseJsonMediaTypeFormatter     System.Net.Http.Formatting.BufferedMediaTypeFormatter     System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter     System.Net.Http.Formatting.XmlMediaTypeFormatter     System.Web.Http.OData.Formatter.ODataMediaTypeFormatter     System.Web.OData.Formatter.ODataMediaTypeFormatter

Syntax

public abstract class MediaTypeFormatter
public ref class MediaTypeFormatter abstract
[<AbstractClass>]
type MediaTypeFormatter = class end
Public MustInherit Class MediaTypeFormatter

Constructors

Name Description
MediaTypeFormatter() Initializes a new instance of the MediaTypeFormatter class.
MediaTypeFormatter(MediaTypeFormatter) Initializes a new instance of the MediaTypeFormatter class.

Properties

Name Description
MaxHttpCollectionKeys Gets or sets the maximum number of keys stored in a T: System.Collections.Specialized.NameValueCollection.
MediaTypeMappings Gets the mutable collection of MediaTypeMapping objects that match HTTP requests to media types.
RequiredMemberSelector Gets or sets the IRequiredMemberSelector instance used to determine required members.
SupportedEncodings Gets the mutable collection of character encodings supported bythis MediaTypeFormatter.
SupportedMediaTypes Gets the mutable collection of media types supported bythis MediaTypeFormatter.

Methods

Name Description
CanReadType(Type) Queries whether this MediaTypeFormatter can deserializean object of the specified type.
CanWriteType(Type) Queries whether this MediaTypeFormatter can serializean object of the specified type.
Equals(Object) (Inherited from Object.)
Finalize() (Inherited from Object.)
GetDefaultValueForType(Type) Gets the default value for the specified type.
GetHashCode() (Inherited from Object.)
GetPerRequestFormatterInstance(Type, HttpRequestMessage, MediaTypeHeaderValue) Returns a specialized instance of the MediaTypeFormatter that can format a response for the given parameters.
GetType() (Inherited from Object.)
MemberwiseClone() (Inherited from Object.)
ReadFromStreamAsync(Type, Stream, HttpContent, IFormatterLogger) Asynchronously deserializes an object of the specified type.
ReadFromStreamAsync(Type, Stream, HttpContent, IFormatterLogger, CancellationToken) Asynchronously deserializes an object of the specified type.
SelectCharacterEncoding(HttpContentHeaders) Determines the best character encoding for reading or writing an HTTP entity body, given a set of content headers.
SetDefaultContentHeaders(Type, HttpContentHeaders, MediaTypeHeaderValue) Sets the default headers for content that will be formatted using this formatter. This method is called from the ObjectContent constructor. This implementation sets the Content-Type header to the value of mediaType if it is not null. If it is null it sets the Content-Type to the default media type of this formatter. If the Content-Type does not specify a charset it will set it using this formatters configured Encoding.
ToString() (Inherited from Object.)
WriteToStreamAsync(Type, Object, Stream, HttpContent, TransportContext) Asynchronously writes an object of the specified type.
WriteToStreamAsync(Type, Object, Stream, HttpContent, TransportContext, CancellationToken) Asynchronously writes an object of the specified type.

Extension Methods

Name Description
AddQueryStringMapping(String, String, MediaTypeHeaderValue) Overloaded. (Defined by MediaTypeFormatterExtensions.)
AddQueryStringMapping(String, String, String) Overloaded. (Defined by MediaTypeFormatterExtensions.)
AddRequestHeaderMapping(String, String, StringComparison, Boolean, MediaTypeHeaderValue) Overloaded. (Defined by MediaTypeFormatterExtensions.)
AddRequestHeaderMapping(String, String, StringComparison, Boolean, String) Overloaded. (Defined by MediaTypeFormatterExtensions.)

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

System.Net.Http.Formatting Namespace

Return to top