Partager via


MediaTypeFormatter.WriteToStreamAsync Method

Asynchronously writes 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 WriteToStreamAsync ( _
    type As Type, _
    value As Object, _
    writeStream As Stream, _
    content As HttpContent, _
    transportContext As TransportContext _
) As Task
'Usage
Dim instance As MediaTypeFormatter 
Dim type As Type 
Dim value As Object 
Dim writeStream As Stream 
Dim content As HttpContent 
Dim transportContext As TransportContext 
Dim returnValue As Task 

returnValue = instance.WriteToStreamAsync(type, _
    value, writeStream, content, transportContext)
public virtual Task WriteToStreamAsync(
    Type type,
    Object value,
    Stream writeStream,
    HttpContent content,
    TransportContext transportContext
)
public:
virtual Task^ WriteToStreamAsync(
    Type^ type, 
    Object^ value, 
    Stream^ writeStream, 
    HttpContent^ content, 
    TransportContext^ transportContext
)
abstract WriteToStreamAsync : 
        type:Type * 
        value:Object * 
        writeStream:Stream * 
        content:HttpContent * 
        transportContext:TransportContext -> Task  
override WriteToStreamAsync : 
        type:Type * 
        value:Object * 
        writeStream:Stream * 
        content:HttpContent * 
        transportContext:TransportContext -> Task
public function WriteToStreamAsync(
    type : Type, 
    value : Object, 
    writeStream : Stream, 
    content : HttpContent, 
    transportContext : TransportContext
) : Task

Parameters

  • type
    Type: System.Type

    The type of the object to write.

  • value
    Type: System.Object

    The object value to write. It may be null.

  • content
    Type: HttpContent

    The HttpContent if available. It may be null.

Return Value

Type: System.Threading.Tasks.Task
A Task that will perform the write.

Exceptions

Exception Condition
NotSupportedException

Derived types need to support writing.

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 writeStream upon completion. The stream will be closed independently when the HttpContent instance is disposed.

See Also

Reference

MediaTypeFormatter Class

System.Net.Http.Formatting Namespace