TextMediaTypeFormatter
Ecng.Net
A media type formatter for processing text-based content.
Implementiert: IMediaTypeFormatter
Konstruktoren
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.
Eigenschaften
MediaType
public string MediaType { get; }
value = textMediaTypeFormatter.MediaType
Gets the media type this formatter handles (e.g. "application/json").
Methoden
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.
Rückgabe: 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.
Rückgabe: The serialized HTTP content.