Table of Contents

Class StreamExtensions

Namespace
Fluxzy.Misc.Streams
Assembly
Fluxzy.Core.dll
public static class StreamExtensions
Inheritance
StreamExtensions
Inherited Members

Methods

CopyDetailed(Stream, Stream, byte[], Action<int>, CancellationToken)

public static ValueTask<long> CopyDetailed(this Stream source, Stream destination, byte[] buffer, Action<int> onContentCopied, CancellationToken cancellationToken)

Parameters

source Stream
destination Stream
buffer byte[]
onContentCopied Action<int>
cancellationToken CancellationToken

Returns

ValueTask<long>

CopyDetailed(Stream, Stream, int, Action<int>, CancellationToken)

public static ValueTask<long> CopyDetailed(this Stream source, Stream destination, int bufferSize, Action<int> onContentCopied, CancellationToken cancellationToken)

Parameters

source Stream
destination Stream
bufferSize int
onContentCopied Action<int>
cancellationToken CancellationToken

Returns

ValueTask<long>

CopyToThenDisposeDestination(Stream, Stream)

public static void CopyToThenDisposeDestination(this Stream src, Stream dest)

Parameters

src Stream
dest Stream

Drain(Stream, int, bool)

public static int Drain(this Stream stream, int bufferSize = 16384, bool disposeStream = false)

Parameters

stream Stream
bufferSize int
disposeStream bool

Returns

int

DrainAsync(Stream, int, bool)

public static ValueTask<int> DrainAsync(this Stream stream, int bufferSize = 16384, bool disposeStream = false)

Parameters

stream Stream
bufferSize int
disposeStream bool

Returns

ValueTask<int>

DrainUntil(Stream, int, int, bool)

public static bool DrainUntil(this Stream stream, int byteCount, int bufferSize = 16384, bool disposeStream = false)

Parameters

stream Stream
byteCount int
bufferSize int
disposeStream bool

Returns

bool

FillArray(Stream, byte[])

public static long FillArray(this Stream stream, byte[] destinationArray)

Parameters

stream Stream
destinationArray byte[]

Returns

long

ReadAtLeast(Stream, Memory<byte>, int, CancellationToken)

public static int ReadAtLeast(this Stream origin, Memory<byte> buffer, int atLeastLength, CancellationToken cancellationToken = default)

Parameters

origin Stream
buffer Memory<byte>
atLeastLength int
cancellationToken CancellationToken

Returns

int

ReadAtLeastAsync(Stream, Memory<byte>, int, CancellationToken)

public static ValueTask<int> ReadAtLeastAsync(this Stream origin, Memory<byte> buffer, int atLeastLength, CancellationToken cancellationToken = default)

Parameters

origin Stream
buffer Memory<byte>
atLeastLength int
cancellationToken CancellationToken

Returns

ValueTask<int>

ReadExact(Stream, Span<byte>)

public static bool ReadExact(this Stream origin, Span<byte> buffer)

Parameters

origin Stream
buffer Span<byte>

Returns

bool

ReadExactAsync(Stream, Memory<byte>, CancellationToken)

public static ValueTask<bool> ReadExactAsync(this Stream origin, Memory<byte> buffer, CancellationToken cancellationToken)

Parameters

origin Stream
buffer Memory<byte>
cancellationToken CancellationToken

Returns

ValueTask<bool>

ReadMaxLengthOrNull(Stream, int)

public static byte[]? ReadMaxLengthOrNull(this Stream stream, int maximum)

Parameters

stream Stream
maximum int

Returns

byte[]

ReadMaximum(Stream, Span<byte>)

public static int ReadMaximum(this Stream origin, Span<byte> buffer)

Parameters

origin Stream
buffer Span<byte>

Returns

int

ReadToEndGreedy(Stream)

public static string ReadToEndGreedy(this Stream stream)

Parameters

stream Stream

Returns

string

SeekableStreamToBytes(Stream, byte[])

public static int SeekableStreamToBytes(this Stream origin, byte[] buffer)

Parameters

origin Stream
buffer byte[]

Returns

int

ToArrayGreedy(Stream)

public static byte[] ToArrayGreedy(this Stream stream)

Parameters

stream Stream

Returns

byte[]

ToArrayGreedyAsync(Stream)

public static Task<byte[]> ToArrayGreedyAsync(this Stream stream)

Parameters

stream Stream

Returns

Task<byte[]>

ToBase64String(Stream, bool)

public static string ToBase64String(this Stream stream, bool dispose = false)

Parameters

stream Stream
dispose bool

Returns

string