Class StreamTransferObject
Represents object which content is represented by Stream.
Inherited Members
Namespace: DotNext.IO
Assembly: DotNext.IO.dll
Syntax
public class StreamTransferObject : Disposable, IDisposable, IDataTransferObject, IAsyncDisposable
Constructors
| Edit this page View SourceStreamTransferObject(Stream, bool)
Represents object which content is represented by Stream.
Declaration
public StreamTransferObject(Stream content, bool leaveOpen)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | content | The message content. |
| bool | leaveOpen | true to leave the stream open after StreamTransferObject object is disposed; otherwise, false. |
Properties
| Edit this page View SourceIsReusable
Indicates that the content of this message can be copied to the output stream or pipe multiple times.
Declaration
public virtual bool IsReusable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
| Edit this page View SourceDispose(bool)
Releases resources associated with this object.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | true if called from Dispose(); false if called from finalizer ~Disposable(). |
Overrides
| Edit this page View SourceDisposeAsync()
Asynchronously releases the resources associated with this object.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask | A task that represents the asynchronous dispose operation. |
DisposeAsyncCore()
Releases managed resources associated with this object asynchronously.
Declaration
protected override ValueTask DisposeAsyncCore()
Returns
| Type | Description |
|---|---|
| ValueTask | The task representing asynchronous execution of this method. |
Overrides
Remarks
This method makes sense only if derived class implements IAsyncDisposable interface.
LoadFromAsync(IDataTransferObject, CancellationToken)
Loads the content from another data transfer object.
Declaration
public ValueTask LoadFromAsync(IDataTransferObject source, CancellationToken token = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataTransferObject | source | The content source. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask | The task representing asynchronous state of content loading. |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The operation has been canceled. |
| NotSupportedException | The underlying stream does not support seeking. |
TransformAsync<TResult, TTransformation>(TTransformation, CancellationToken)
Parses the encapsulated stream.
Declaration
public ValueTask<TResult> TransformAsync<TResult, TTransformation>(TTransformation transformation, CancellationToken token = default) where TTransformation : IDataTransferObject.ITransformation<TResult>
Parameters
| Type | Name | Description |
|---|---|---|
| TTransformation | transformation | The parser instance. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<TResult> | The converted DTO content. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of result. |
| TTransformation | The type of parser. |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The operation has been canceled. |