MediaTypeFormatter.ReadFromStreamAsync Method (Type, Stream, HttpContent, IFormatterLogger, CancellationToken)

Asynchronously deserializes an object of the specified type.

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

Syntax

'Declaration
Public Overridable Function ReadFromStreamAsync ( _
    type As Type, _
    readStream As Stream, _
    content As HttpContent, _
    formatterLogger As IFormatterLogger, _
    cancellationToken As CancellationToken _
) As Task(Of Object)
'Usage
Dim instance As MediaTypeFormatter 
Dim type As Type 
Dim readStream As Stream 
Dim content As HttpContent 
Dim formatterLogger As IFormatterLogger 
Dim cancellationToken As CancellationToken 
Dim returnValue As Task(Of Object)

returnValue = instance.ReadFromStreamAsync(type, _
    readStream, content, formatterLogger, _
    cancellationToken)
public virtual Task<Object> ReadFromStreamAsync(
    Type type,
    Stream readStream,
    HttpContent content,
    IFormatterLogger formatterLogger,
    CancellationToken cancellationToken
)
public:
virtual Task<Object^>^ ReadFromStreamAsync(
    Type^ type, 
    Stream^ readStream, 
    HttpContent^ content, 
    IFormatterLogger^ formatterLogger, 
    CancellationToken cancellationToken
)
abstract ReadFromStreamAsync : 
        type:Type * 
        readStream:Stream * 
        content:HttpContent * 
        formatterLogger:IFormatterLogger * 
        cancellationToken:CancellationToken -> Task<Object> 
override ReadFromStreamAsync : 
        type:Type * 
        readStream:Stream * 
        content:HttpContent * 
        formatterLogger:IFormatterLogger * 
        cancellationToken:CancellationToken -> Task<Object> 
public function ReadFromStreamAsync(
    type : Type, 
    readStream : Stream, 
    content : HttpContent, 
    formatterLogger : IFormatterLogger, 
    cancellationToken : CancellationToken
) : Task<Object>

Parameters

  • type
    Type: System.Type
    The type of the object to deserialize.
  • content
    Type: HttpContent
    The HttpContent, if available. It may be null.

Return Value

Type: System.Threading.Tasks.Task<Object>
A Task whose result will be an object of the given type.

Remarks

This implementation throws a NotSupportedException. Derived types should override this method if the formatter supports reading. An implementation of this method should not close readStream upon completion. The stream will be closed independently when the HttpContent instance is disposed.

See Also

Reference

MediaTypeFormatter Class

ReadFromStreamAsync Overload

System.Net.Http.Formatting Namespace