MediaTypeFormatter.WriteToStreamAsync Method (Type, Object, Stream, HttpContent, TransportContext)

Asynchronously writes an object of the specified type.

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

public virtual Task WriteToStreamAsync(
	Type type,
	Object value,
	Stream writeStream,
	HttpContent content,
	TransportContext transportContext
)

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.
writeStream
Type: System.IO.Stream
The Stream to which to write.
content
Type: HttpContent
The HttpContent if available. It may be null.
transportContext
Type: System.Net.TransportContext
The TransportContext if available. It may be null.

Return Value

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

ExceptionCondition
NotSupportedException

Derived types need to support writing.

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.

Show: