Interface IDataTransferObject
Represents structured data unit that can be transferred over wire.
Namespace: DotNext.IO
Assembly: DotNext.IO.dll
Syntax
public interface IDataTransferObject
Properties
| Improve this Doc View SourceIsReusable
Indicates that the content of this object can be copied to the output stream or pipe multiple times.
Declaration
bool IsReusable { get; }
Property Value
Type | Description |
---|---|
Boolean |
Length
Gets length of the object payload, in bytes.
Declaration
long? Length { get; }
Property Value
Type | Description |
---|---|
Nullable<Int64> |
Remarks
If value is null then length of the payload cannot be determined.
Methods
| Improve this Doc View SourceDecodeAsync<TResult, TDecoder>(PipeReader, TDecoder, CancellationToken)
Decodes the data using pipe reader.
Declaration
static ValueTask<TResult> DecodeAsync<TResult, TDecoder>(PipeReader input, TDecoder transformation, CancellationToken token)
where TDecoder : IDataTransferObject.IDecoder<TResult>
Parameters
Type | Name | Description |
---|---|---|
PipeReader | input | The pipe reader used for decoding. |
TDecoder | transformation | The decoder. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TResult> | The decoded stream. |
Type Parameters
Name | Description |
---|---|
TResult | The type of result. |
TDecoder | The type of parser. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
DecodeAsync<TResult, TDecoder>(Stream, TDecoder, Boolean, CancellationToken)
Decodes the stream.
Declaration
static ValueTask<TResult> DecodeAsync<TResult, TDecoder>(Stream input, TDecoder transformation, bool resetStream, CancellationToken token)
where TDecoder : IDataTransferObject.IDecoder<TResult>
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The stream to decode. |
TDecoder | transformation | The decoder. |
Boolean | resetStream | true to reset stream position after decoding. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TResult> | The decoded stream. |
Type Parameters
Name | Description |
---|---|
TResult | The type of result. |
TDecoder | The type of parser. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
GetObjectDataAsync<TResult, TDecoder>(TDecoder, CancellationToken)
Converts data transfer object to another type.
Declaration
virtual 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. |
Remarks
The default implementation copies the content into memory before parsing.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
WriteToAsync<TWriter>(TWriter, CancellationToken)
Transforms this object to serialized form.
Declaration
ValueTask WriteToAsync<TWriter>(TWriter writer, CancellationToken token)
where TWriter : IAsyncBinaryWriter
Parameters
Type | Name | Description |
---|---|---|
TWriter | writer | The binary writer. |
CancellationToken | token | The toke that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing state of asynchronous execution. |
Type Parameters
Name | Description |
---|---|
TWriter | The type of writer. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |