Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Static class: RT.Util.ExtensionMethods.StreamExtensions

Summary

Provides extension methods on the Stream type.

Static methods

int
FillBuffer(this Stream stream, byte[] buffer, int offset, int length)
Attempts to fill the buffer with the specified number of bytes from the stream. If there are fewer bytes left in the stream than requested then all available bytes will be read into the buffer.
Task<int>
FillBufferAsync(this Stream stream, byte[] buffer, int offset, int length, CancellationToken? token = null)
byte[]
Read(this Stream stream, int length)
Attempts to read the specified number of bytes from the stream. If there are fewer bytes left before the end of the stream, a shorter (possibly empty) array is returned.
byte[]
ReadAllBytes(this Stream stream)
Reads all bytes until the end of stream and returns them in a byte array.
Task<byte[]>
ReadAllBytesAsync(this Stream stream, CancellationToken? token = null)
long
ReadAllBytesGetLength(this Stream stream)
Reads all bytes until the end of stream and returns the number of bytes thus read without allocating too much memory.
Task<long>
ReadAllBytesGetLengthAsync(this Stream stream, CancellationToken? token = null)
string
ReadAllText(this Stream stream, Encoding encoding = null)
Reads all bytes from the current Stream and converts them into text using the specified encoding.
Task<string>
ReadAllTextAsync(this Stream stream, Encoding encoding = null, CancellationToken? token = null)
Task<byte[]>
ReadAsync(this Stream stream, int length, CancellationToken? token = null)
Attempts to read the specified number of bytes from the stream. If there are fewer bytes left before the end of the stream, a shorter (possibly empty) array is returned.
decimal
ReadDecimalOptim(this Stream stream)
Decodes a decimal encoded by StreamExtensions.WriteDecimalOptim(this Stream, decimal).
int
ReadInt32Optim(this Stream stream)
Decodes an integer encoded by StreamExtensions.WriteInt32Optim(this Stream, int) or StreamExtensions.WriteUInt32Optim(this Stream, uint).
long
ReadInt64Optim(this Stream stream)
Decodes an integer encoded by StreamExtensions.WriteInt64Optim(this Stream, long) or StreamExtensions.WriteUInt64Optim(this Stream, ulong).
uint
ReadUInt32Optim(this Stream stream)
Decodes an integer encoded by StreamExtensions.WriteUInt32Optim(this Stream, uint).
ulong
ReadUInt64Optim(this Stream stream)
Decodes an integer encoded by StreamExtensions.WriteUInt64Optim(this Stream, ulong).
void
Write(this Stream stream, byte[] data)
Writes the specified data to the current stream.
Task
WriteAsync(this Stream stream, byte[] data, CancellationToken? token = null)
Writes the specified data to the current stream.
void
WriteDecimalOptim(this Stream stream, decimal val)
Encodes a decimal in a variable number of bytes, using fewer bytes for frequently-occurring low-precision values. (see also remarks)
void
WriteInt32Optim(this Stream stream, int val)
Encodes a 32-bit signed integer in a variable number of bytes, using fewer bytes for values closer to zero. (see also remarks)
void
WriteInt64Optim(this Stream stream, long val)
Encodes a 64-bit signed integer in a variable number of bytes, using fewer bytes for values closer to zero. (see also remarks)
void
WriteUInt32Optim(this Stream stream, uint val)
Encodes a 32-bit unsigned integer in a variable number of bytes, using fewer bytes for smaller values. (see also remarks)
void
WriteUInt64Optim(this Stream stream, ulong val)
Encodes a 64-bit unsigned integer in a variable number of bytes, using fewer bytes for smaller values. (see also remarks)
void
WriteUtf8(this Stream stream, string text)
Encodes the specified string as UTF-8 and writes it to the current stream.