Show / Hide Table of Contents

Class StreamSource

Represents Stream factory methods.

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

Methods

| Improve this Doc View Source

AsStream(SparseBufferWriter<Byte>, Boolean)

Creates a stream over sparse memory.

Declaration
public static Stream AsStream(this SparseBufferWriter<byte> writer, bool readable)
Parameters
Type Name Description
SparseBufferWriter<Byte> writer

Sparse memory buffer.

Boolean readable

true to create readable stream; false to create writable stream.

Returns
Type Description
Stream

Sparse memory stream.

| Improve this Doc View Source

AsStream(ArraySegment<Byte>, Boolean)

Converts segment of an array to the stream.

Declaration
public static Stream AsStream(this ArraySegment<byte> segment, bool writable = false)
Parameters
Type Name Description
ArraySegment<Byte> segment

The array of bytes.

Boolean writable

Determines whether the stream supports writing.

Returns
Type Description
Stream

The stream representing the array segment.

| Improve this Doc View Source

AsStream(ReadOnlySequence<Byte>)

Converts read-only sequence of bytes to a read-only stream.

Declaration
public static Stream AsStream(this ReadOnlySequence<byte> sequence)
Parameters
Type Name Description
ReadOnlySequence<Byte> sequence

The sequence of bytes.

Returns
Type Description
Stream

The stream over sequence of bytes.

| Improve this Doc View Source

AsStream(ReadOnlyMemory<Byte>)

Converts read-only memory to a read-only stream.

Declaration
public static Stream AsStream(this ReadOnlyMemory<byte> memory)
Parameters
Type Name Description
ReadOnlyMemory<Byte> memory

The read-only memory.

Returns
Type Description
Stream

The stream over memory of bytes.

| Improve this Doc View Source

AsStream<TWriter>(TWriter, Action<TWriter>, Func<TWriter, CancellationToken, Task>)

Returns writable stream associated with the buffer writer.

Declaration
public static Stream AsStream<TWriter>(this TWriter writer, Action<TWriter> flush = null, Func<TWriter, CancellationToken, Task> flushAsync = null)

    where TWriter : class, IBufferWriter<byte>
Parameters
Type Name Description
TWriter writer

The writer to be wrapped by the stream.

Action<TWriter> flush

Optional synchronous flush action.

Func<TWriter, CancellationToken, Task> flushAsync

Optiona asynchronous flush action.

Returns
Type Description
Stream

The writable stream wrapping buffer writer.

Type Parameters
Name Description
TWriter

The type of the writer.

| Improve this Doc View Source

AsStream<TArg>(ReadOnlySpanAction<Byte, TArg>, TArg, Action<TArg>, Func<TArg, CancellationToken, Task>)

Returns writable stream that wraps the provided delegate for writing data.

Declaration
public static Stream AsStream<TArg>(this ReadOnlySpanAction<byte, TArg> writer, TArg arg, Action<TArg> flush = null, Func<TArg, CancellationToken, Task> flushAsync = null)
Parameters
Type Name Description
ReadOnlySpanAction<Byte, TArg> writer

The callback that is called automatically.

TArg arg

The arg to be passed to the callback.

Action<TArg> flush

Optional synchronous flush action.

Func<TArg, CancellationToken, Task> flushAsync

Optiona asynchronous flush action.

Returns
Type Description
Stream

The writable stream wrapping the callback.

Type Parameters
Name Description
TArg

The type of the object that represents the state.

| Improve this Doc View Source

AsStream<TArg>(Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask>, TArg, Action<TArg>, Func<TArg, CancellationToken, Task>)

Returns writable stream that wraps the provided delegate for writing data.

Declaration
public static Stream AsStream<TArg>(this Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> writer, TArg arg, Action<TArg> flush = null, Func<TArg, CancellationToken, Task> flushAsync = null)
Parameters
Type Name Description
Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask> writer

The callback that is called automatically.

TArg arg

The arg to be passed to the callback.

Action<TArg> flush

Optional synchronous flush action.

Func<TArg, CancellationToken, Task> flushAsync

Optiona asynchronous flush action.

Returns
Type Description
Stream

The writable stream wrapping the callback.

Type Parameters
Name Description
TArg

The type of the object that represents the state.

| Improve this Doc View Source

GetWrittenBytesAsStream(PooledArrayBufferWriter<Byte>)

Gets written content as a read-only stream.

Declaration
[Obsolete("Use DotNext.IO.StreamSource.AsStream in combination with WrittenArray or WrittenMemory property instead", true)]
public static Stream GetWrittenBytesAsStream(PooledArrayBufferWriter<byte> writer)
Parameters
Type Name Description
PooledArrayBufferWriter<Byte> writer

The buffer writer.

Returns
Type Description
Stream

The stream representing written bytes.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX