Swiss Army Knife
General utility tools for Scada Minds
Static Public Member Functions | List of all members
StreamExtensions Class Reference

Extensions for performing stream-related tasks. More...

Static Public Member Functions

static async Task< MemoryStream > AsMemoryStreamAsync (this Stream sourceStream)
 Copies the stream over to a new memoryStream. The new MemoryStream will be at position 0. More...
 
static async Task< byte[]> ToByteArrayAsync (this Stream sourceStream)
 Fully reads a stream into a byte array. Starts at the current stream position. More...
 
static string ContentToString (this Stream sourceStream, Encoding? encoding=null)
 Take a stream and return the content as a string. Reads from current stream position, and does not reset the stream position afterwards. Defaults to UTF-8 encoding. More...
 

Detailed Description

Extensions for performing stream-related tasks.

Member Function Documentation

◆ AsMemoryStreamAsync()

static async Task<MemoryStream> AsMemoryStreamAsync ( this Stream  sourceStream)
inlinestatic

Copies the stream over to a new memoryStream. The new MemoryStream will be at position 0.

Parameters
sourceStreamA MemoryStream to copy over to a new stream. Will be exhausted afterwards.
Returns
A new MemoryStream with the content from sourceStream This stream will be at position 0.

◆ ContentToString()

static string ContentToString ( this Stream  sourceStream,
Encoding?  encoding = null 
)
inlinestatic

Take a stream and return the content as a string. Reads from current stream position, and does not reset the stream position afterwards. Defaults to UTF-8 encoding.

◆ ToByteArrayAsync()

static async Task<byte[]> ToByteArrayAsync ( this Stream  sourceStream)
inlinestatic

Fully reads a stream into a byte array. Starts at the current stream position.

Parameters
sourceStreamA MemoryStream to copy over to a byte array. Will be exhausted afterwards.
Returns
A byte array with the content from sourceStream .

The documentation for this class was generated from the following file: