Show / Hide Table of Contents

Class StreamExtensions

Represents high-level read/write methods for the stream.

Inheritance
Object
StreamExtensions
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.IO.dll
Syntax
public static class StreamExtensions
Remarks

This class provides alternative way to read and write typed data from/to the stream without instantiation of BinaryReader and BinaryWriter.

Methods

| Improve this Doc View Source

AsBufferWriter(Stream, Nullable<MemoryAllocator<Byte>>)

Converts the stream to IBufferWriter<T>.

Declaration
public static IFlushableBufferWriter<byte> AsBufferWriter(this Stream output, MemoryAllocator<byte>? allocator = default(MemoryAllocator<byte>? ))
Parameters
Type Name Description
Stream output

The stream to convert.

Nullable<MemoryAllocator<Byte>> allocator

The allocator of the buffer.

Returns
Type Description
IFlushableBufferWriter<Byte>

The buffered stream writer.

Exceptions
Type Condition
ArgumentNullException

output is null.

ArgumentException

output is not writable stream.

| Improve this Doc View Source

CopyTo(Stream, IBufferWriter<Byte>, Int32, CancellationToken)

Synchronously reads the bytes from the current stream and writes them to buffer writer, using a specified cancellation token.

Declaration
public static long CopyTo(this Stream source, IBufferWriter<byte> destination, int bufferSize = 0, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream source

The source stream.

IBufferWriter<Byte> destination

The writer to which the contents of the current stream will be copied.

Int32 bufferSize

The size, in bytes, of the buffer.

CancellationToken token

The token to monitor for cancellation requests.

Returns
Type Description
Int64

The number of copied bytes.

Exceptions
Type Condition
ArgumentNullException

destination is null.

ArgumentOutOfRangeException

bufferSize is negative or zero.

NotSupportedException

source doesn't support reading.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

CopyTo(Stream, Stream, Span<Byte>, CancellationToken)

Synchronously reads the bytes from the source stream and writes them to another stream, using a specified buffer.

Declaration
public static long CopyTo(this Stream source, Stream destination, Span<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream source

The source stream to read from.

Stream destination

The destination stream to write into.

Span<Byte> buffer

The buffer used to hold copied content temporarily.

CancellationToken token

The token that can be used to cancel this operation.

Returns
Type Description
Int64

The total number of copied bytes.

| Improve this Doc View Source

CopyToAsync(Stream, IBufferWriter<Byte>, Int32, CancellationToken)

Asynchronously reads the bytes from the current stream and writes them to buffer writer, using a specified cancellation token.

Declaration
public static Task<long> CopyToAsync(this Stream source, IBufferWriter<byte> destination, int bufferSize = 0, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream source

The source stream.

IBufferWriter<Byte> destination

The writer to which the contents of the current stream will be copied.

Int32 bufferSize

The size, in bytes, of the buffer.

CancellationToken token

The token to monitor for cancellation requests.

Returns
Type Description
Task<Int64>

The number of copied bytes.

Exceptions
Type Condition
ArgumentNullException

destination is null.

ArgumentOutOfRangeException

bufferSize is negative or zero.

NotSupportedException

source doesn't support reading.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

CopyToAsync(Stream, Stream, Memory<Byte>, CancellationToken)

Asynchronously reads the bytes from the source stream and writes them to another stream, using a specified buffer.

Declaration
public static ValueTask<long> CopyToAsync(this Stream source, Stream destination, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream source

The source stream to read from.

Stream destination

The destination stream to write into.

Memory<Byte> buffer

The buffer used to hold copied content temporarily.

CancellationToken token

The token that can be used to cancel this operation.

Returns
Type Description
ValueTask<Int64>

The total number of copied bytes.

| Improve this Doc View Source

Read<T>(Stream)

Deserializes the value type from the stream.

Declaration
public static T Read<T>(this Stream stream)

    where T : struct
Parameters
Type Name Description
Stream stream

The stream to read from.

Returns
Type Description
T

The value deserialized from the stream.

Type Parameters
Name Description
T

The value type to be deserialized.

Exceptions
Type Condition
EndOfStreamException

The end of the stream is reached.

| Improve this Doc View Source

Read<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Int32, CancellationToken)

Reads the entire content using the specified delegate.

Declaration
public static void Read<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, int bufferSize = 256, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

ReadOnlySpanAction<Byte, TArg> reader

The content reader.

TArg arg

The argument to be passed to the content reader.

Int32 bufferSize

The size of the buffer used to read data.

CancellationToken token

The token that can be used to cancel operation.

Type Parameters
Name Description
TArg

The type of the argument to be passed to the content reader.

Exceptions
Type Condition
ArgumentOutOfRangeException

bufferSize is less than or equal to zero.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

Read<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Span<Byte>, CancellationToken)

Reads the entire content using the specified delegate.

Declaration
public static void Read<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, Span<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

ReadOnlySpanAction<Byte, TArg> reader

The content reader.

TArg arg

The argument to be passed to the content reader.

Span<Byte> buffer

The buffer allocated by the caller.

CancellationToken token

The token that can be used to cancel operation.

Type Parameters
Name Description
TArg

The type of the argument to be passed to the content reader.

Exceptions
Type Condition
ArgumentException

buffer is empty.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Int32, CancellationToken)

Reads the entire content using the specified delegate.

Declaration
public static Task ReadAsync<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, int bufferSize = 256, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

ReadOnlySpanAction<Byte, TArg> reader

The content reader.

TArg arg

The argument to be passed to the content reader.

Int32 bufferSize

The size of the buffer used to read data.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Type Parameters
Name Description
TArg

The type of the argument to be passed to the content reader.

Exceptions
Type Condition
ArgumentOutOfRangeException

bufferSize is less than or equal to zero.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Memory<Byte>, CancellationToken)

Reads the entire content using the specified delegate.

Declaration
public static Task ReadAsync<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

ReadOnlySpanAction<Byte, TArg> reader

The content reader.

TArg arg

The argument to be passed to the content reader.

Memory<Byte> buffer

The buffer allocated by the caller.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Type Parameters
Name Description
TArg

The type of the argument to be passed to the content reader.

Exceptions
Type Condition
ArgumentException

buffer is empty.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<TArg>(Stream, Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask>, TArg, Int32, CancellationToken)

Reads the entire content using the specified delegate.

Declaration
public static Task ReadAsync<TArg>(this Stream stream, Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> reader, TArg arg, int bufferSize = 256, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask> reader

The content reader.

TArg arg

The argument to be passed to the content reader.

Int32 bufferSize

The size of the buffer used to read data.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Type Parameters
Name Description
TArg

The type of the argument to be passed to the content reader.

Exceptions
Type Condition
ArgumentOutOfRangeException

bufferSize is less than or equal to zero.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<TArg>(Stream, Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask>, TArg, Memory<Byte>, CancellationToken)

Reads the entire content using the specified delegate.

Declaration
public static Task ReadAsync<TArg>(this Stream stream, Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> reader, TArg arg, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask> reader

The content reader.

TArg arg

The argument to be passed to the content reader.

Memory<Byte> buffer

The buffer allocated by the caller.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
Task

The task representing asynchronous execution of this method.

Type Parameters
Name Description
TArg

The type of the argument to be passed to the content reader.

Exceptions
Type Condition
ArgumentException

buffer is empty.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<T>(Stream, Memory<Byte>, CancellationToken)

Asynchronously deserializes the value type from the stream.

Declaration
public static ValueTask<T> ReadAsync<T>(this Stream stream, Memory<byte> buffer, CancellationToken token = default(CancellationToken))

    where T : struct
Parameters
Type Name Description
Stream stream

The stream to read from.

Memory<Byte> buffer

The buffer that is allocated by the caller.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<T>

The value deserialized from the stream.

Type Parameters
Name Description
T

The value type to be deserialized.

Exceptions
Type Condition
EndOfStreamException

The end of the stream is reached.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<T>(Stream, CancellationToken)

Asynchronously deserializes the value type from the stream.

Declaration
public static ValueTask<T> ReadAsync<T>(this Stream stream, CancellationToken token = default(CancellationToken))

    where T : struct
Parameters
Type Name Description
Stream stream

The stream to read from.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<T>

The value deserialized from the stream.

Type Parameters
Name Description
T

The value type to be deserialized.

Exceptions
Type Condition
EndOfStreamException

The end of the stream is reached.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadBlock(Stream, Span<Byte>)

Reads exact number of bytes.

Declaration
public static void ReadBlock(this Stream stream, Span<byte> output)
Parameters
Type Name Description
Stream stream

The stream to read from.

Span<Byte> output

A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.

Exceptions
Type Condition
EndOfStreamException

The end of the stream is reached.

| Improve this Doc View Source

ReadBlockAsync(Stream, Memory<Byte>, CancellationToken)

Reads exact number of bytes asynchronously.

Declaration
public static ValueTask ReadBlockAsync(this Stream stream, Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

Memory<Byte> output

A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Exceptions
Type Condition
EndOfStreamException

The end of the stream is reached.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadByte(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 8-bit unsigned integer from its string representation.

Declaration
public static byte ReadByte(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
Byte

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadByteAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 8-bit unsigned integer from its string representation.

Declaration
public static ValueTask<byte> ReadByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Byte>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadByteAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 8-bit unsigned integer from its string representation.

Declaration
public static ValueTask<byte> ReadByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Byte>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadBytes(Stream, Span<Byte>)

Reads exact number of bytes.

Declaration
[Obsolete("Use ReadBlock extension method instead")]
public static void ReadBytes(Stream stream, Span<byte> output)
Parameters
Type Name Description
Stream stream

The stream to read from.

Span<Byte> output

A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.

Exceptions
Type Condition
EndOfStreamException

The end of the stream is reached.

| Improve this Doc View Source

ReadBytesAsync(Stream, Memory<Byte>, CancellationToken)

Reads exact number of bytes asynchronously.

Declaration
[Obsolete("Use ReadBlockAsync extension method instead")]
public static ValueTask ReadBytesAsync(Stream stream, Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

Memory<Byte> output

A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Exceptions
Type Condition
EndOfStreamException

The end of the stream is reached.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTime(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, DateTimeStyles, IFormatProvider)

Decodes DateTime from its string representation.

Declaration
public static DateTime ReadDateTime(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
DateTime

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

| Improve this Doc View Source

ReadDateTime(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String[], DateTimeStyles, IFormatProvider)

Decodes DateTime from its string representation.

Declaration
public static DateTime ReadDateTime(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

String[] formats

An array of allowable formats.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
DateTime

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

| Improve this Doc View Source

ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTime from its string representation.

Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTime>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTime from its string representation.

Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTime>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTime from its string representation.

Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

String[] formats

An array of allowable formats.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTime>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, String[], Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTime from its string representation.

Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

String[] formats

An array of allowable formats.

Memory<Byte> buffer

The buffer that is allocated by the caller.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTime>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTimeOffset(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, DateTimeStyles, IFormatProvider)

Decodes DateTimeOffset from its string representation.

Declaration
public static DateTimeOffset ReadDateTimeOffset(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
DateTimeOffset

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

| Improve this Doc View Source

ReadDateTimeOffset(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String[], DateTimeStyles, IFormatProvider)

Decodes DateTimeOffset from its string representation.

Declaration
public static DateTimeOffset ReadDateTimeOffset(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

String[] formats

An array of allowable formats.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
DateTimeOffset

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

| Improve this Doc View Source

ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTimeOffset from its string representation.

Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTimeOffset>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTimeOffset from its string representation.

Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTimeOffset>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTimeOffset from its string representation.

Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

String[] formats

An array of allowable formats.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTimeOffset>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, String[], Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTimeOffset from its string representation.

Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

String[] formats

An array of allowable formats.

Memory<Byte> buffer

The buffer that is allocated by the caller.

DateTimeStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<DateTimeOffset>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The date/time string is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDecimal(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes Decimal from its string representation.

Declaration
public static decimal ReadDecimal(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingSign | NumberStyles.AllowTrailingWhite | NumberStyles.Integer | NumberStyles.Number, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
Decimal

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadDecimalAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes Decimal from its string representation.

Declaration
public static ValueTask<decimal> ReadDecimalAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingSign | NumberStyles.AllowTrailingWhite | NumberStyles.Integer | NumberStyles.Number, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Decimal>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDecimalAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes Decimal from its string representation.

Declaration
public static ValueTask<decimal> ReadDecimalAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingSign | NumberStyles.AllowTrailingWhite | NumberStyles.Integer | NumberStyles.Number, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Decimal>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDouble(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes double-precision floating-point number from its string representation.

Declaration
public static double ReadDouble(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
Double

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadDoubleAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes double-precision floating-point number from its string representation.

Declaration
public static ValueTask<double> ReadDoubleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Double>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadDoubleAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes double-precision floating-point number from its string representation.

Declaration
public static ValueTask<double> ReadDoubleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Double>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadGuid(Stream, StringLengthEncoding, DecodingContext, Span<Byte>)

Decodes Guid from its string representation.

Declaration
public static Guid ReadGuid(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

Returns
Type Description
Guid

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

GUID value is in incorrect format.

| Improve this Doc View Source

ReadGuid(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String)

Decodes Guid from its string representation.

Declaration
public static Guid ReadGuid(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string format)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

String format

The expected format of GUID value.

Returns
Type Description
Guid

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

GUID value is in incorrect format.

| Improve this Doc View Source

ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, String, CancellationToken)

Decodes Guid from its string representation.

Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, string format, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The expected format of GUID value.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Guid>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

GUID value is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, CancellationToken)

Decodes Guid from its string representation.

Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Guid>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

GUID value is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, String, CancellationToken)

Decodes Guid from its string representation.

Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string format, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

String format

The expected format of GUID value.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Guid>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

GUID value is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, CancellationToken)

Decodes Guid from its string representation.

Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Guid>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

GUID value is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadInt16(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 16-bit signed integer from its string representation.

Declaration
public static short ReadInt16(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
Int16

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadInt16Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 16-bit signed integer from its string representation.

Declaration
public static ValueTask<short> ReadInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Int16>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadInt16Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 16-bit signed integer from its string representation.

Declaration
public static ValueTask<short> ReadInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Int16>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadInt32(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 32-bit signed integer from its string representation.

Declaration
public static int ReadInt32(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
Int32

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadInt32Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 32-bit signed integer from its string representation.

Declaration
public static ValueTask<int> ReadInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Int32>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadInt32Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 32-bit signed integer from its string representation.

Declaration
public static ValueTask<int> ReadInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Int32>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadInt64(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 64-bit signed integer from its string representation.

Declaration
public static long ReadInt64(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
Int64

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadInt64Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 64-bit signed integer from its string representation.

Declaration
public static ValueTask<long> ReadInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Int64>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadInt64Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 64-bit signed integer from its string representation.

Declaration
public static ValueTask<long> ReadInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Int64>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadSByte(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 8-bit signed integer from its string representation.

Declaration
[CLSCompliant(false)]
public static sbyte ReadSByte(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
SByte

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadSByteAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 8-bit signed integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<sbyte> ReadSByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<SByte>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadSByteAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 8-bit signed integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<sbyte> ReadSByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<SByte>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadSingle(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes single-precision floating-point number from its string representation.

Declaration
public static float ReadSingle(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
Single

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadSingleAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes single-precision floating-point number from its string representation.

Declaration
public static ValueTask<float> ReadSingleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Single>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadSingleAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes single-precision floating-point number from its string representation.

Declaration
public static ValueTask<float> ReadSingleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<Single>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadString(Stream, StringLengthEncoding, DecodingContext, Span<Byte>)

Reads a length-prefixed string using the specified encoding and supplied reusable buffer.

Declaration
public static string ReadString(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

Returns
Type Description
String

The string decoded from the log entry content stream.

Remarks

This method decodes string length (in bytes) from stream in contrast to ReadString(Stream, Int32, DecodingContext, Span<Byte>).

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

ReadString(Stream, StringLengthEncoding, Encoding)

Reads a length-prefixed string using the specified encoding.

Declaration
public static string ReadString(this Stream stream, StringLengthEncoding lengthFormat, Encoding encoding)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

Encoding encoding

The encoding used to decode bytes from stream into characters.

Returns
Type Description
String

The string decoded from the log entry content stream.

Remarks

This method decodes string length (in bytes) from stream in contrast to ReadString(Stream, Int32, Encoding).

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

ReadString(Stream, Int32, DecodingContext, Span<Byte>)

Reads the string using the specified encoding and supplied reusable buffer.

Declaration
public static string ReadString(this Stream stream, int length, in DecodingContext context, Span<byte> buffer)
Parameters
Type Name Description
Stream stream

The stream to read from.

Int32 length

The length of the string, in bytes.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

Returns
Type Description
String

The string decoded from the log entry content stream.

Remarks

buffer length can be less than length but should be enough to decode at least one character of the specified encoding.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

| Improve this Doc View Source

ReadString(Stream, Int32, Encoding)

Reads the string using the specified encoding.

Declaration
public static string ReadString(this Stream stream, int length, Encoding encoding)
Parameters
Type Name Description
Stream stream

The stream to read from.

Int32 length

The length of the string, in bytes.

Encoding encoding

The encoding used to decode bytes from stream into characters.

Returns
Type Description
String

The string decoded from the log entry content stream.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

| Improve this Doc View Source

ReadStringAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, CancellationToken)

Reads a length-prefixed string asynchronously using the specified encoding and supplied reusable buffer.

Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<String>

The string decoded from the log entry content stream.

Remarks

This method decodes string length (in bytes) from stream in contrast to ReadStringAsync(Stream, Int32, DecodingContext, Memory<Byte>, CancellationToken).

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

ReadStringAsync(Stream, StringLengthEncoding, Encoding, CancellationToken)

Reads a length-prefixed string asynchronously using the specified encoding and supplied reusable buffer.

Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, StringLengthEncoding lengthFormat, Encoding encoding, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

Encoding encoding

The encoding used to decode bytes from stream into characters.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<String>

The string decoded from the log entry content stream.

Remarks

This method decodes string length (in bytes) from stream in contrast to ReadStringAsync(Stream, Int32, Encoding, CancellationToken).

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

ReadStringAsync(Stream, Int32, DecodingContext, Memory<Byte>, CancellationToken)

Reads the string asynchronously using the specified encoding and supplied reusable buffer.

Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, int length, DecodingContext context, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

Int32 length

The length of the string, in bytes.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<String>

The string decoded from the log entry content stream.

Remarks

buffer length can be less than length but should be enough to decode at least one character of the specified encoding.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadStringAsync(Stream, Int32, Encoding, CancellationToken)

Reads the string asynchronously using the specified encoding and supplied reusable buffer.

Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, int length, Encoding encoding, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

Int32 length

The length of the string, in bytes.

Encoding encoding

The encoding used to decode bytes from stream into characters.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<String>

The string decoded from the log entry content stream.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadTimeSpan(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, IFormatProvider)

Parses TimeSpan from its string representation encoded in the underlying stream.

Declaration
public static TimeSpan ReadTimeSpan(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The decoding context containing string characters encoding.

Span<Byte> buffer

The buffer that is allocated by the caller.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
TimeSpan

The parsed value.

Exceptions
Type Condition
FormatException

The time span is in incorrect format.

EndOfStreamException

The underlying source doesn't contain necessary amount of bytes to decode the value.

| Improve this Doc View Source

ReadTimeSpan(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String[], TimeSpanStyles, IFormatProvider)

Parses DateTimeOffset from its string representation encoded in the underlying stream.

Declaration
public static TimeSpan ReadTimeSpan(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string[] formats, TimeSpanStyles style = TimeSpanStyles.None, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The decoding context containing string characters encoding.

Span<Byte> buffer

The buffer that is allocated by the caller.

String[] formats

An array of allowable formats.

TimeSpanStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
TimeSpan

The parsed value.

Exceptions
Type Condition
FormatException

The time span is in incorrect format.

EndOfStreamException

The underlying source doesn't contain necessary amount of bytes to decode the value.

| Improve this Doc View Source

ReadTimeSpanAsync(Stream, StringLengthEncoding, DecodingContext, IFormatProvider, CancellationToken)

Parses TimeSpan from its string representation encoded in the underlying stream.

Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The decoding context containing string characters encoding.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<TimeSpan>

The parsed value.

Exceptions
Type Condition
FormatException

The time span is in incorrect format.

OperationCanceledException

The operation has been canceled.

EndOfStreamException

The underlying source doesn't contain necessary amount of bytes to decode the value.

| Improve this Doc View Source

ReadTimeSpanAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, IFormatProvider, CancellationToken)

Parses TimeSpan from its string representation encoded in the underlying stream.

Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The decoding context containing string characters encoding.

Memory<Byte> buffer

The buffer that is allocated by the caller.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<TimeSpan>

The parsed value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

FormatException

The time span is in incorrect format.

OperationCanceledException

The operation has been canceled.

EndOfStreamException

The underlying source doesn't contain necessary amount of bytes to decode the value.

| Improve this Doc View Source

ReadTimeSpanAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, String[], TimeSpanStyles, IFormatProvider, CancellationToken)

Parses TimeSpan from its string representation encoded in the underlying stream.

Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, string[] formats, TimeSpanStyles style = TimeSpanStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The decoding context containing string characters encoding.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String[] formats

An array of allowable formats.

TimeSpanStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<TimeSpan>

The parsed value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

FormatException

The time span is in incorrect format.

OperationCanceledException

The operation has been canceled.

EndOfStreamException

The underlying source doesn't contain necessary amount of bytes to decode the value.

| Improve this Doc View Source

ReadTimeSpanAsync(Stream, StringLengthEncoding, DecodingContext, String[], TimeSpanStyles, IFormatProvider, CancellationToken)

Parses TimeSpan from its string representation encoded in the underlying stream.

Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, TimeSpanStyles style = TimeSpanStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The decoding context containing string characters encoding.

String[] formats

An array of allowable formats.

TimeSpanStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<TimeSpan>

The parsed value.

Exceptions
Type Condition
FormatException

The time span is in incorrect format.

OperationCanceledException

The operation has been canceled.

EndOfStreamException

The underlying source doesn't contain necessary amount of bytes to decode the value.

| Improve this Doc View Source

ReadUInt16(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 16-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ushort ReadUInt16(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
UInt16

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadUInt16Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 16-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<ushort> ReadUInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<UInt16>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadUInt16Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 16-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<ushort> ReadUInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<UInt16>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadUInt32(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 32-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static uint ReadUInt32(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
UInt32

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadUInt32Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 32-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<uint> ReadUInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<UInt32>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadUInt32Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 32-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<uint> ReadUInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<UInt32>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadUInt64(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)

Decodes 64-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ulong ReadUInt64(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Span<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Returns
Type Description
UInt64

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

| Improve this Doc View Source

ReadUInt64Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)

Decodes 64-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<ulong> ReadUInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<UInt64>

The decoded value.

Exceptions
Type Condition
EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadUInt64Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)

Decodes 64-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<ulong> ReadUInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to read from.

StringLengthEncoding lengthFormat

The format of the string length encoded in the stream.

DecodingContext context

The text decoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

NumberStyles style

A bitwise combination of the enumeration values that indicates the style elements.

IFormatProvider provider

An object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask<UInt64>

The decoded value.

Exceptions
Type Condition
ArgumentException

buffer too small for decoding characters.

EndOfStreamException

Unexpected end of stream.

FormatException

The number is in incorrect format.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

Write(Stream, ReadOnlySequence<Byte>, CancellationToken)

Writes sequence of bytes to the underlying stream synchronously.

Declaration
public static void Write(this Stream stream, in ReadOnlySequence<byte> sequence, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

ReadOnlySequence<Byte> sequence

The sequence of bytes.

CancellationToken token

The token that can be used to cancel the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

Write<T>(Stream, T)

Serializes value to the stream.

Declaration
public static void Write<T>(this Stream stream, in T value)

    where T : struct
Parameters
Type Name Description
Stream stream

The stream to write into.

T value

The value to be written into the stream.

Type Parameters
Name Description
T

The value type to be serialized.

| Improve this Doc View Source

WriteAsync(Stream, ReadOnlySequence<Byte>, CancellationToken)

Writes sequence of bytes to the underlying stream asynchronously.

Declaration
public static ValueTask WriteAsync(this Stream stream, ReadOnlySequence<byte> sequence, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

ReadOnlySequence<Byte> sequence

The sequence of bytes.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteAsync<T>(Stream, T, Memory<Byte>, CancellationToken)

Asynchronously serializes value to the stream.

Declaration
public static ValueTask WriteAsync<T>(this Stream stream, T value, Memory<byte> buffer, CancellationToken token = default(CancellationToken))

    where T : struct
Parameters
Type Name Description
Stream stream

The stream to write into.

T value

The value to be written into the stream.

Memory<Byte> buffer

The buffer that is used for serialization.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Type Parameters
Name Description
T

The value type to be serialized.

| Improve this Doc View Source

WriteAsync<T>(Stream, T, CancellationToken)

Asynchronously serializes value to the stream.

Declaration
public static ValueTask WriteAsync<T>(this Stream stream, T value, CancellationToken token = default(CancellationToken))

    where T : struct
Parameters
Type Name Description
Stream stream

The stream to write into.

T value

The value to be written into the stream.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Type Parameters
Name Description
T

The value type to be serialized.

| Improve this Doc View Source

WriteAsync<TArg>(Stream, Func<TArg, CancellationToken, ValueTask<ReadOnlyMemory<Byte>>>, TArg, CancellationToken)

Writes the memory blocks supplied by the specified delegate.

Declaration
public static Task<long> WriteAsync<TArg>(this Stream stream, Func<TArg, CancellationToken, ValueTask<ReadOnlyMemory<byte>>> supplier, TArg arg, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The destination stream.

Func<TArg, CancellationToken, ValueTask<ReadOnlyMemory<Byte>>> supplier

The delegate supplying memory blocks.

TArg arg

The argument to be passed to the supplier.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
Task<Int64>

The number of written bytes.

Type Parameters
Name Description
TArg

The type of the argument to be passed to the supplier.

Remarks

Copy process will be stopped when supplier returns empty ReadOnlyMemory<T>.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteByte(Stream, Byte, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 8-bit unsigned integer as a string.

Declaration
public static void WriteByte(this Stream stream, byte value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

Byte value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteByteAsync(Stream, Byte, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 8-bit unsigned integer as a string.

Declaration
public static ValueTask WriteByteAsync(this Stream stream, byte value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Byte value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteByteAsync(Stream, Byte, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 8-bit unsigned integer as a string.

Declaration
public static ValueTask WriteByteAsync(this Stream stream, byte value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Byte value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDateTime(Stream, DateTime, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes DateTime as a string.

Declaration
public static void WriteDateTime(this Stream stream, DateTime value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

DateTime value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteDateTimeAsync(Stream, DateTime, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes DateTime as a string.

Declaration
public static ValueTask WriteDateTimeAsync(this Stream stream, DateTime value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

DateTime value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDateTimeAsync(Stream, DateTime, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes DateTime as a string.

Declaration
public static ValueTask WriteDateTimeAsync(this Stream stream, DateTime value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

DateTime value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDateTimeOffset(Stream, DateTimeOffset, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes DateTimeOffset as a string.

Declaration
public static void WriteDateTimeOffset(this Stream stream, DateTimeOffset value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

DateTimeOffset value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteDateTimeOffsetAsync(Stream, DateTimeOffset, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes DateTimeOffset as a string.

Declaration
public static ValueTask WriteDateTimeOffsetAsync(this Stream stream, DateTimeOffset value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

DateTimeOffset value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDateTimeOffsetAsync(Stream, DateTimeOffset, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes DateTimeOffset as a string.

Declaration
public static ValueTask WriteDateTimeOffsetAsync(this Stream stream, DateTimeOffset value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

DateTimeOffset value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDecimal(Stream, Decimal, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes Decimal as a string.

Declaration
public static void WriteDecimal(this Stream stream, decimal value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

Decimal value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteDecimalAsync(Stream, Decimal, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes double-precision floating-point number as a string.

Declaration
public static ValueTask WriteDecimalAsync(this Stream stream, decimal value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Decimal value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDecimalAsync(Stream, Decimal, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes double-precision floating-pointer number as a string.

Declaration
public static ValueTask WriteDecimalAsync(this Stream stream, decimal value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Decimal value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDouble(Stream, Double, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes double-precision floating-point number as a string.

Declaration
public static void WriteDouble(this Stream stream, double value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

Double value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteDoubleAsync(Stream, Double, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes double-precision floating-point number as a string.

Declaration
public static ValueTask WriteDoubleAsync(this Stream stream, double value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Double value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteDoubleAsync(Stream, Double, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes double-precision floating-pointer number as a string.

Declaration
public static ValueTask WriteDoubleAsync(this Stream stream, double value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Double value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteGuid(Stream, Guid, StringLengthEncoding, Encoding, ReadOnlySpan<Char>)

Encodes Guid as a string.

Declaration
public static void WriteGuid(this Stream stream, Guid value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>))
Parameters
Type Name Description
Stream stream

The stream to write into.

Guid value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

| Improve this Doc View Source

WriteGuidAsync(Stream, Guid, StringLengthEncoding, EncodingContext, Memory<Byte>, String, CancellationToken)

Encodes Guid as a string.

Declaration
public static ValueTask WriteGuidAsync(this Stream stream, Guid value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Guid value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteGuidAsync(Stream, Guid, StringLengthEncoding, EncodingContext, String, CancellationToken)

Encodes Guid as a string.

Declaration
public static ValueTask WriteGuidAsync(this Stream stream, Guid value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Guid value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteInt16(Stream, Int16, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 16-bit signed integer as a string.

Declaration
public static void WriteInt16(this Stream stream, short value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

Int16 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteInt16Async(Stream, Int16, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 16-bit signed integer as a string.

Declaration
public static ValueTask WriteInt16Async(this Stream stream, short value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Int16 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteInt16Async(Stream, Int16, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 16-bit signed integer as a string.

Declaration
public static ValueTask WriteInt16Async(this Stream stream, short value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Int16 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteInt32(Stream, Int32, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 32-bit signed integer as a string.

Declaration
public static void WriteInt32(this Stream stream, int value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

Int32 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteInt32Async(Stream, Int32, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 32-bit signed integer as a string.

Declaration
public static ValueTask WriteInt32Async(this Stream stream, int value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Int32 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteInt32Async(Stream, Int32, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 16-bit signed integer as a string.

Declaration
public static ValueTask WriteInt32Async(this Stream stream, int value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Int32 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteInt64(Stream, Int64, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 64-bit signed integer as a string.

Declaration
public static void WriteInt64(this Stream stream, long value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

Int64 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteInt64Async(Stream, Int64, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 64-bit signed integer as a string.

Declaration
public static ValueTask WriteInt64Async(this Stream stream, long value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Int64 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteInt64Async(Stream, Int64, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 64-bit signed integer as a string.

Declaration
public static ValueTask WriteInt64Async(this Stream stream, long value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Int64 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteSByte(Stream, SByte, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 8-bit signed integer as a string.

Declaration
[CLSCompliant(false)]
public static void WriteSByte(this Stream stream, sbyte value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

SByte value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteSByteAsync(Stream, SByte, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 8-bit signed integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteSByteAsync(this Stream stream, sbyte value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

SByte value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteSByteAsync(Stream, SByte, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 8-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteSByteAsync(this Stream stream, sbyte value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

SByte value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteSingle(Stream, Single, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes single-precision floating-point number as a string.

Declaration
public static void WriteSingle(this Stream stream, float value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

Single value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteSingleAsync(Stream, Single, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes single-precision floating-point number as a string.

Declaration
public static ValueTask WriteSingleAsync(this Stream stream, float value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Single value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteSingleAsync(Stream, Single, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes single-precision floating-pointer number as a string.

Declaration
public static ValueTask WriteSingleAsync(this Stream stream, float value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

Single value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteString(Stream, ReadOnlySpan<Char>, EncodingContext, Span<Byte>, Nullable<StringLengthEncoding>)

Writes a length-prefixed or raw string to the stream using supplied reusable buffer.

Declaration
public static void WriteString(this Stream stream, ReadOnlySpan<char> value, in EncodingContext context, Span<byte> buffer, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ))
Parameters
Type Name Description
Stream stream

The stream to write into.

ReadOnlySpan<Char> value

The string to be encoded.

EncodingContext context

The encoding.

Span<Byte> buffer

The buffer allocated by the caller needed for characters encoding.

Nullable<StringLengthEncoding> lengthFormat

String length encoding format; or null to prevent encoding of string length.

Remarks

This method doesn't encode the length of the string.

Exceptions
Type Condition
ArgumentException

buffer is too small for encoding minimal portion of value.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteString(Stream, ReadOnlySpan<Char>, Encoding, Nullable<StringLengthEncoding>)

Writes a length-prefixed or raw string to the stream.

Declaration
public static void WriteString(this Stream stream, ReadOnlySpan<char> value, Encoding encoding, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ))
Parameters
Type Name Description
Stream stream

The stream to write into.

ReadOnlySpan<Char> value

The string to be encoded.

Encoding encoding

The string encoding.

Nullable<StringLengthEncoding> lengthFormat

String length encoding format; or null to prevent encoding of string length.

Remarks

This method doesn't encode the length of the string.

Exceptions
Type Condition
ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteStringAsync(Stream, ReadOnlyMemory<Char>, EncodingContext, Memory<Byte>, Nullable<StringLengthEncoding>, CancellationToken)

Writes a length-prefixed or raw string to the stream asynchronously using supplied reusable buffer.

Declaration
public static ValueTask WriteStringAsync(this Stream stream, ReadOnlyMemory<char> value, EncodingContext context, Memory<byte> buffer, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ), CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

ReadOnlyMemory<Char> value

The string to be encoded.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer allocated by the caller needed for characters encoding.

Nullable<StringLengthEncoding> lengthFormat

String length encoding format; or null to prevent encoding of string length.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Remarks

This method doesn't encode the length of the string.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentException

buffer is too small for encoding minimal portion of value.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteStringAsync(Stream, ReadOnlyMemory<Char>, Encoding, Nullable<StringLengthEncoding>, CancellationToken)

Writes a length-prefixed or raw string to the stream asynchronously.

Declaration
public static ValueTask WriteStringAsync(this Stream stream, ReadOnlyMemory<char> value, Encoding encoding, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ), CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

ReadOnlyMemory<Char> value

The string to be encoded.

Encoding encoding

The encoding context.

Nullable<StringLengthEncoding> lengthFormat

Represents string length encoding format.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Remarks

This method doesn't encode the length of the string.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteTimeSpan(Stream, TimeSpan, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes TimeSpan as a string.

Declaration
public static void WriteTimeSpan(this Stream stream, TimeSpan value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

TimeSpan value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteTimeSpanAsync(Stream, TimeSpan, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes TimeSpan as a string.

Declaration
public static ValueTask WriteTimeSpanAsync(this Stream stream, TimeSpan value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

TimeSpan value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteTimeSpanAsync(Stream, TimeSpan, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes TimeSpan as a string.

Declaration
public static ValueTask WriteTimeSpanAsync(this Stream stream, TimeSpan value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

TimeSpan value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteUInt16(Stream, UInt16, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 16-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static void WriteUInt16(this Stream stream, ushort value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt16 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteUInt16Async(Stream, UInt16, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 16-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt16Async(this Stream stream, ushort value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt16 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteUInt16Async(Stream, UInt16, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 16-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt16Async(this Stream stream, ushort value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt16 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteUInt32(Stream, UInt32, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 32-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static void WriteUInt32(this Stream stream, uint value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt32 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteUInt32Async(Stream, UInt32, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 32-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt32Async(this Stream stream, uint value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt32 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteUInt32Async(Stream, UInt32, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 16-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt32Async(this Stream stream, uint value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt32 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteUInt64(Stream, UInt64, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)

Encodes 64-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static void WriteUInt64(this Stream stream, ulong value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt64 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

Encoding encoding

The string encoding.

ReadOnlySpan<Char> format

A span containing the characters that represent a standard or custom format string.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

| Improve this Doc View Source

WriteUInt64Async(Stream, UInt64, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)

Encodes 64-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt64Async(this Stream stream, ulong value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt64 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

Memory<Byte> buffer

The buffer that is allocated by the caller.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

WriteUInt64Async(Stream, UInt64, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)

Encodes 64-bit unsigned integer as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt64Async(this Stream stream, ulong value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream stream

The stream to write into.

UInt64 value

The value to encode.

StringLengthEncoding lengthFormat

String length encoding format.

EncodingContext context

The encoding context.

String format

The format to use.

IFormatProvider provider

An optional object that supplies culture-specific formatting information.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

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