TextMediaTypeFormatter
Ecng.Net
A media type formatter for processing text-based content.
Implementa: IMediaTypeFormatter
Construtores
TextMediaTypeFormatter
public TextMediaTypeFormatter(IEnumerable<string> mediaTypes)
textMediaTypeFormatter = TextMediaTypeFormatter(mediaTypes)
Initializes a new instance of the TextMediaTypeFormatter class with the specified media types.
- mediaTypes
- A collection of media type strings.
Propriedades
MediaType
public string MediaType { get; }
value = textMediaTypeFormatter.MediaType
Gets the media type this formatter handles (e.g. "application/json").
Métodos
DeserializeAsync``1
public Task<T> DeserializeAsync<T>(HttpContent content, CancellationToken cancellationToken)
result = textMediaTypeFormatter.DeserializeAsync(content, cancellationToken)
Deserializes the HTTP content into an instance of .
- content
- The HTTP content to deserialize.
- cancellationToken
- A cancellation token.
Retorna: A task representing the deserialized value.
Serialize
public HttpContent Serialize(object value)
result = textMediaTypeFormatter.Serialize(value)
Serializes the specified value into HttpContent.
- value
- The value to serialize.
Retorna: The serialized HTTP content.