IMediaTypeFormatter

Ecng.Net

Abstracts HTTP content serialization and deserialization for REST API clients.

Свойства

MediaType
public string MediaType { get; }
value = iMediaTypeFormatter.MediaType

Gets the media type this formatter handles (e.g. "application/json").

Методы

DeserializeAsync``1
public Task<T> DeserializeAsync<T>(HttpContent content, CancellationToken cancellationToken)
result = iMediaTypeFormatter.DeserializeAsync(content, cancellationToken)

Deserializes the HTTP content into an instance of .

content
The HTTP content to deserialize.
cancellationToken
A cancellation token.

Возвращает: A task representing the deserialized value.

Serialize
public HttpContent Serialize(object value)
result = iMediaTypeFormatter.Serialize(value)

Serializes the specified value into HttpContent.

value
The value to serialize.

Возвращает: The serialized HTTP content.