Show / Hide Table of Contents

Class PointerExtensions

Extensions for Pointer<T> data type.

Inheritance
object
PointerExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.IO
Assembly: DotNext.Unsafe.dll
Syntax
public static class PointerExtensions

Methods

View Source

Create<T>(Pointer<T>, long, FileAccess)

Returns representation of the memory identified by this pointer in the form of the stream.

Declaration
public static Stream Create<T>(Pointer<T> source, long count, FileAccess access = FileAccess.ReadWrite) where T : unmanaged
Parameters
Type Name Description
Pointer<T> source

The source pointer that points to the data to be wrapped by the stream.

long count

The number of elements of type T referenced by this memory.

FileAccess access

The type of the access supported by the returned stream.

Returns
Type Description
Stream

The stream representing the memory identified by this pointer.

Type Parameters
Name Description
T
Remarks

This method returns Stream compatible over the memory identified by this pointer. No copying is performed.

Exceptions
Type Condition
ArgumentOutOfRangeException

count is less than 0.

View Source

ReadFromAsync<T>(Pointer<T>, Stream, long, CancellationToken)

Copies bytes from the given stream to the memory location identified by this pointer asynchronously.

Declaration
public static ValueTask<long> ReadFromAsync<T>(this Pointer<T> receiver, Stream source, long count, CancellationToken token = default) where T : unmanaged
Parameters
Type Name Description
Pointer<T> receiver
Stream source

The source stream.

long count

The number of elements of type T to be copied.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<long>

The actual number of copied elements.

Type Parameters
Name Description
T
Exceptions
Type Condition
NullPointerException

This pointer is zero.

ArgumentException

The stream is not readable.

ArgumentOutOfRangeException

count is less than zero.

OperationCanceledException

The operation has been canceled.

View Source

ReadFrom<T>(Pointer<T>, Stream, long)

Copies bytes from the given stream to the memory location identified by this pointer.

Declaration
public static long ReadFrom<T>(this Pointer<T> receiver, Stream source, long count) where T : unmanaged
Parameters
Type Name Description
Pointer<T> receiver
Stream source

The source stream.

long count

The number of elements of type T to be copied.

Returns
Type Description
long

The actual number of copied elements.

Type Parameters
Name Description
T
Exceptions
Type Condition
NullPointerException

This pointer is zero.

ArgumentException

The stream is not readable.

ArgumentOutOfRangeException

count is less than zero.

View Source

WriteToAsync<T>(Pointer<T>, Stream, long, CancellationToken)

Copies bytes from the memory location identified by this pointer to the stream asynchronously.

Declaration
public static ValueTask WriteToAsync<T>(this Pointer<T> receiver, Stream destination, long count, CancellationToken token = default) where T : unmanaged
Parameters
Type Name Description
Pointer<T> receiver
Stream destination

The destination stream.

long count

The number of elements of type T to be copied.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task instance representing asynchronous state of the copying process.

Type Parameters
Name Description
T
Exceptions
Type Condition
NullPointerException

This pointer is equal to zero.

ArgumentOutOfRangeException

count is less than zero.

ArgumentException

The stream is not writable.

OperationCanceledException

The operation has been canceled.

View Source

WriteTo<T>(Pointer<T>, Stream, long)

Copies bytes from the memory location identified by this pointer to the stream.

Declaration
[CLSCompliant(false)]
public static void WriteTo<T>(this Pointer<T> receiver, Stream destination, long count) where T : unmanaged
Parameters
Type Name Description
Pointer<T> receiver
Stream destination

The destination stream.

long count

The number of elements of type T to be copied.

Type Parameters
Name Description
T
Exceptions
Type Condition
NullPointerException

This pointer is equal to zero.

ArgumentException

The stream is not writable.

ArgumentOutOfRangeException

count is less than zero.

  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾