Class StreamTransferObject
Represents object which content is represented by Stream.
Namespace: DotNext.IO
Assembly: DotNext.IO.dll
Syntax
public class StreamTransferObject : Disposable, IDataTransferObject, IAsyncDisposable
Constructors
| Improve this Doc View SourceStreamTransferObject(Stream, Boolean)
Initializes a new message.
Declaration
public StreamTransferObject(Stream content, bool leaveOpen)
Parameters
Type | Name | Description |
---|---|---|
Stream | content | The message content. |
Boolean | leaveOpen | true to leave the stream open after StreamTransferObject object is disposed; otherwise, false. |
Properties
| Improve this Doc 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 |
---|---|
Boolean |
Methods
| Improve this Doc View SourceDispose(Boolean)
Releases resources associated with this object.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | true if called from |
DisposeAsync()
Asynchronously releases the resources associated with this object.
Declaration
public virtual ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask | A task that represents the asynchronous dispose operation. |
GetObjectDataAsync<TResult, TDecoder>(TDecoder, CancellationToken)
Parses the encapsulated stream.
Declaration
public ValueTask<TResult> GetObjectDataAsync<TResult, TDecoder>(TDecoder parser, CancellationToken token = default(CancellationToken))
where TDecoder : IDataTransferObject.IDecoder<TResult>
Parameters
Type | Name | Description |
---|---|---|
TDecoder | parser | 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. |
TDecoder | The type of parser. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
LoadFromAsync(IDataTransferObject, CancellationToken)
Loads the content from another data transfer object.
Declaration
public ValueTask LoadFromAsync(IDataTransferObject source, CancellationToken token = default(CancellationToken))
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. |
Explicit Interface Implementations
| Improve this Doc View SourceIDataTransferObject.Length
Declaration
long? IDataTransferObject.Length { get; }
Returns
Type | Description |
---|---|
Nullable<Int64> |
IDataTransferObject.WriteToAsync<TWriter>(TWriter, CancellationToken)
Declaration
ValueTask IDataTransferObject.WriteToAsync<TWriter>(TWriter writer, CancellationToken token)
where TWriter : IAsyncBinaryWriter
Parameters
Type | Name | Description |
---|---|---|
TWriter | writer | |
CancellationToken | token |
Returns
Type | Description |
---|---|
ValueTask |
Type Parameters
Name | Description |
---|---|
TWriter |