Class MemoryTransferObject
Represents data transfer object holding the content of the predefined size in the memory.
Inherited Members
Namespace: DotNext.IO
Assembly: DotNext.IO.dll
Syntax
public class MemoryTransferObject : Disposable, IDisposable, IDataTransferObject
Constructors
| Edit this page View SourceMemoryTransferObject(int, MemoryAllocator<byte>?)
Represents data transfer object holding the content of the predefined size in the memory.
Declaration
public MemoryTransferObject(int length, MemoryAllocator<byte>? allocator = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | length | The length, in bytes, of the content. |
| MemoryAllocator<byte> | allocator | The memory allocator. |
Properties
| Edit this page View SourceContent
Gets the content of this object.
Declaration
public Memory<byte> Content { get; }
Property Value
| Type | Description |
|---|---|
| Memory<byte> |
Methods
| Edit this page View SourceDispose(bool)
Releases managed and unmanaged 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 SourceTransformAsync<TResult, TTransformation>(TTransformation, CancellationToken)
Converts data transfer object to another type.
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. |
WriteToAsync<TWriter>(TWriter, CancellationToken)
Transforms this object to serialized form.
Declaration
public 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. |