Show / Hide Table of Contents

Class PipeExtensions

Represents extension method for parsing data stored in pipe.

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

Methods

| Improve this Doc View Source

ComputeHashAsync(PipeReader, HashAlgorithmName, Int32, Memory<Byte>, CancellationToken)

Computes the hash for the pipe.

Declaration
public static ValueTask<int> ComputeHashAsync(this PipeReader reader, HashAlgorithmName name, int count, Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

HashAlgorithmName name

The name of the hash algorithm.

Int32 count

The number of bytes to be added to the hash.

Memory<Byte> output

The buffer used to write the final hash.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
ValueTask<Int32>

The length of the final hash.

Exceptions
Type Condition
ArgumentException

output is too small for the hash.

OperationCanceledException

The operation has been canceled.

EndOfStreamException

Unexpected end of stream.

| Improve this Doc View Source

ComputeHashAsync(PipeReader, HashAlgorithmName, Memory<Byte>, CancellationToken)

Computes the hash for the pipe.

Declaration
public static ValueTask<int> ComputeHashAsync(this PipeReader reader, HashAlgorithmName name, Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

HashAlgorithmName name

The name of the hash algorithm.

Memory<Byte> output

The buffer used to write the final hash.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
ValueTask<Int32>

The length of the final hash.

Exceptions
Type Condition
ArgumentException

output is too small for the hash.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

CopyToAsync(PipeReader, IBufferWriter<Byte>, CancellationToken)

Copies the data from the pipe to the buffer.

Declaration
public static Task<long> CopyToAsync(this PipeReader reader, IBufferWriter<byte> destination, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe to read from.

IBufferWriter<Byte> destination

The buffer writer used as destination.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<Int64>

The number of copied bytes.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

CopyToAsync(PipeReader, Memory<Byte>, CancellationToken)

Reads the block of memory.

Declaration
public static ValueTask<int> CopyToAsync(this PipeReader reader, Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Memory<Byte> output

The block of memory to fill from the pipe.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
ValueTask<Int32>

The actual number of copied bytes.

| Improve this Doc View Source

ReadAsync(PipeReader, Memory<Byte>, CancellationToken)

Reads the block of memory.

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

The pipe reader.

Memory<Byte> output

The block of memory to fill from the pipe.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
EndOfStreamException

Reader doesn't have enough data.

| Improve this Doc View Source

ReadAsync<TArg>(PipeReader, ReadOnlySpanAction<Byte, TArg>, TArg, CancellationToken)

Reads the entire content using the specified delegate.

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

The pipe to read from.

ReadOnlySpanAction<Byte, TArg> consumer

The content reader.

TArg arg

The argument to be passed to the content reader.

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
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Reads the entire content using the specified delegate.

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

The pipe to read from.

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

The content reader.

TArg arg

The argument to be passed to the content reader.

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
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<T>(PipeReader, CancellationToken)

Reads value of blittable type from pipe.

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

    where T : struct
Parameters
Type Name Description
PipeReader reader

The pipe reader.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
ValueTask<T>

The decoded value.

Type Parameters
Name Description
T

The blittable type to decode.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadBlockAsync(PipeReader, Memory<Byte>, CancellationToken)

Reads the block of memory.

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

The pipe reader.

Memory<Byte> output

The block of memory to fill from the pipe.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the operation.

Exceptions
Type Condition
EndOfStreamException

Reader doesn't have enough data.

| Improve this Doc View Source

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

Decodes 8-bit unsigned integer from its string representation.

Declaration
public static ValueTask<byte> ReadByteAsync(this PipeReader reader, 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
PipeReader reader

The pipe 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

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

Decodes DateTime from its string representation.

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

The pipe 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(PipeReader, StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTime from its string representation.

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

The pipe 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

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

Decodes DateTimeOffset from its string representation.

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

The pipe 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(PipeReader, StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)

Decodes DateTimeOffset from its string representation.

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

The pipe 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

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

Decodes Decimal from its string representation.

Declaration
public static ValueTask<decimal> ReadDecimalAsync(this PipeReader reader, 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
PipeReader reader

The pipe 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

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

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

Declaration
public static ValueTask<double> ReadDoubleAsync(this PipeReader reader, 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
PipeReader reader

The pipe 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

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

Decodes Guid from its string representation.

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

The pipe 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(PipeReader, StringLengthEncoding, DecodingContext, CancellationToken)

Decodes Guid from its string representation.

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

The pipe 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

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

Decodes 16-bit signed integer from its string representation.

Declaration
public static ValueTask<short> ReadInt16Async(this PipeReader reader, 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
PipeReader reader

The pipe 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(PipeReader, Boolean, CancellationToken)

Decodes 16-bit signed integer using the specified endianness.

Declaration
public static ValueTask<short> ReadInt16Async(this PipeReader reader, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Boolean littleEndian

true if value is stored in the underlying binary stream as little-endian; otherwise, use big-endian.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<Int16>

The decoded value.

Exceptions
Type Condition
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

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

Decodes 32-bit signed integer from its string representation.

Declaration
public static ValueTask<int> ReadInt32Async(this PipeReader reader, 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
PipeReader reader

The pipe 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(PipeReader, Boolean, CancellationToken)

Decodes 32-bit signed integer using the specified endianness.

Declaration
public static ValueTask<int> ReadInt32Async(this PipeReader reader, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Boolean littleEndian

true if value is stored in the underlying binary stream as little-endian; otherwise, use big-endian.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<Int32>

The decoded value.

Exceptions
Type Condition
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

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

Decodes 64-bit signed integer from its string representation.

Declaration
public static ValueTask<long> ReadInt64Async(this PipeReader reader, 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
PipeReader reader

The pipe 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(PipeReader, Boolean, CancellationToken)

Decodes 64-bit signed integer using the specified endianness.

Declaration
public static ValueTask<long> ReadInt64Async(this PipeReader reader, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Boolean littleEndian

true if value is stored in the underlying binary stream as little-endian; otherwise, use big-endian.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<Int64>

The decoded value.

Exceptions
Type Condition
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

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

Decodes 8-bit signed integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<sbyte> ReadSByteAsync(this PipeReader reader, 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
PipeReader reader

The pipe 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

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

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

Declaration
public static ValueTask<float> ReadSingleAsync(this PipeReader reader, 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
PipeReader reader

The pipe 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

ReadStringAsync(PipeReader, StringLengthEncoding, DecodingContext, CancellationToken)

Decodes string asynchronously from pipe.

Declaration
public static ValueTask<string> ReadStringAsync(this PipeReader reader, StringLengthEncoding lengthFormat, DecodingContext context, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

StringLengthEncoding lengthFormat

Represents string length encoding format.

DecodingContext context

The text decoding context.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<String>

The decoded string.

Exceptions
Type Condition
EndOfStreamException

reader doesn't contain the necessary number of bytes to restore string.

OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

| Improve this Doc View Source

ReadStringAsync(PipeReader, Int32, DecodingContext, CancellationToken)

Decodes string asynchronously from pipe.

Declaration
public static ValueTask<string> ReadStringAsync(this PipeReader reader, int length, DecodingContext context, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Int32 length

The length of the string, in bytes.

DecodingContext context

The text decoding context.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<String>

The decoded string.

Exceptions
Type Condition
EndOfStreamException

reader doesn't contain the necessary number of bytes to restore string.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

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

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

The pipe 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(PipeReader, StringLengthEncoding, DecodingContext, String[], TimeSpanStyles, IFormatProvider, CancellationToken)

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

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

The pipe 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

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

Decodes 16-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<ushort> ReadUInt16Async(this PipeReader reader, 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
PipeReader reader

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(PipeReader, Boolean, CancellationToken)

Decodes 16-bit signed integer using the specified endianness.

Declaration
[CLSCompliant(false)]
public static ValueTask<ushort> ReadUInt16Async(this PipeReader reader, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Boolean littleEndian

true if value is stored in the underlying binary stream as little-endian; otherwise, use big-endian.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<UInt16>

The decoded value.

Exceptions
Type Condition
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

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

Decodes 32-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<uint> ReadUInt32Async(this PipeReader reader, 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
PipeReader reader

The pipe 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(PipeReader, Boolean, CancellationToken)

Decodes 32-bit unsigned integer using the specified endianness.

Declaration
[CLSCompliant(false)]
public static ValueTask<uint> ReadUInt32Async(this PipeReader reader, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Boolean littleEndian

true if value is stored in the underlying binary stream as little-endian; otherwise, use big-endian.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<UInt32>

The decoded value.

Exceptions
Type Condition
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

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

Decodes 64-bit unsigned integer from its string representation.

Declaration
[CLSCompliant(false)]
public static ValueTask<ulong> ReadUInt64Async(this PipeReader reader, 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
PipeReader reader

The pipe 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(PipeReader, Boolean, CancellationToken)

Decodes 64-bit unsigned integer using the specified endianness.

Declaration
[CLSCompliant(false)]
public static ValueTask<ulong> ReadUInt64Async(this PipeReader reader, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeReader reader

The pipe reader.

Boolean littleEndian

true if value is stored in the underlying binary stream as little-endian; otherwise, use big-endian.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<UInt64>

The decoded value.

Exceptions
Type Condition
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

WriteAsync(PipeWriter, ReadOnlySequence<Byte>, CancellationToken)

Writes sequence of bytes to the underlying stream asynchronously.

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

The pipe 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<Int64>

The actual number of bytes written to the pipe.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteAsync<T>(PipeWriter, T, CancellationToken)

Encodes value of blittable type.

Declaration
public static ValueTask<FlushResult> WriteAsync<T>(this PipeWriter writer, T value, CancellationToken token = default(CancellationToken))

    where T : struct
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

T value

The value to be encoded in binary form.

CancellationToken token

The token that can be used to cancel operation.

Returns
Type Description
ValueTask<FlushResult>

The task representing asynchronous result of operation.

Type Parameters
Name Description
T

The blittable type to encode.

| Improve this Doc View Source

WriteAsync<TArg>(PipeWriter, 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 PipeWriter writer, Func<TArg, CancellationToken, ValueTask<ReadOnlyMemory<byte>>> supplier, TArg arg, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

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

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

Encodes 8-bit unsigned integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes DateTime as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteDateTimeAsync(this PipeWriter writer, DateTime value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes DateTimeOffset as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteDateTimeOffsetAsync(this PipeWriter writer, DateTimeOffset value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes Decimal as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteDecimalAsync(this PipeWriter writer, decimal value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

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

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteDoubleAsync(this PipeWriter writer, double value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes Guid as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteGuidAsync(this PipeWriter writer, Guid value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes 16-bit signed integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteInt16Async(PipeWriter, Int16, Boolean, CancellationToken)

Encodes 16-bit signed integer asynchronously.

Declaration
public static ValueTask<FlushResult> WriteInt16Async(this PipeWriter writer, short value, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

Int16 value

The value to encode.

Boolean littleEndian

true to use little-endian encoding; false to use big-endian encoding.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes 32-bit signed integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteInt32Async(PipeWriter, Int32, Boolean, CancellationToken)

Encodes 32-bit signed integer asynchronously.

Declaration
public static ValueTask<FlushResult> WriteInt32Async(this PipeWriter writer, int value, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

Int32 value

The value to encode.

Boolean littleEndian

true to use little-endian encoding; false to use big-endian encoding.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes 64-bit signed integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteInt64Async(PipeWriter, Int64, Boolean, CancellationToken)

Encodes 64-bit signed integer asynchronously.

Declaration
public static ValueTask<FlushResult> WriteInt64Async(this PipeWriter writer, long value, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

Int64 value

The value to encode.

Boolean littleEndian

true to use little-endian encoding; false to use big-endian encoding.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes 8-bit signed integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

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

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteSingleAsync(this PipeWriter writer, float value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteStringAsync(PipeWriter, ReadOnlyMemory<Char>, EncodingContext, Int32, Nullable<StringLengthEncoding>, CancellationToken)

Encodes the string to bytes and write them to pipe asynchronously.

Declaration
public static ValueTask WriteStringAsync(this PipeWriter writer, ReadOnlyMemory<char> value, EncodingContext context, int bufferSize = 0, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ), CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

ReadOnlyMemory<Char> value

The block of characters to encode.

EncodingContext context

The text encoding context.

Int32 bufferSize

The buffer size (in bytes) used for 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 operation.

Returns
Type Description
ValueTask

The result of operation.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

lengthFormat is invalid.

EndOfStreamException

Pipe closed unexpectedly.

| Improve this Doc View Source

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

Encodes TimeSpan as a string.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteTimeSpanAsync(this PipeWriter writer, TimeSpan value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes 16-bit unsigned integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteUInt16Async(PipeWriter, UInt16, Boolean, CancellationToken)

Encodes 16-bit unsigned integer asynchronously.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteUInt16Async(this PipeWriter writer, ushort value, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

UInt16 value

The value to encode.

Boolean littleEndian

true to use little-endian encoding; false to use big-endian encoding.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes 32-bit unsigned integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteUInt32Async(PipeWriter, UInt32, Boolean, CancellationToken)

Encodes 32-bit unsigned integer asynchronously.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteUInt32Async(this PipeWriter writer, uint value, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

UInt32 value

The value to encode.

Boolean littleEndian

true to use little-endian encoding; false to use big-endian encoding.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

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

Encodes 64-bit unsigned integer as a string.

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

The buffer writer.

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<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

WriteUInt64Async(PipeWriter, UInt64, Boolean, CancellationToken)

Encodes 64-bit unsigned integer asynchronously.

Declaration
[CLSCompliant(false)]
public static ValueTask<FlushResult> WriteUInt64Async(this PipeWriter writer, ulong value, bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
PipeWriter writer

The pipe writer.

UInt64 value

The value to encode.

Boolean littleEndian

true to use little-endian encoding; false to use big-endian encoding.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<FlushResult>

The task representing state of asynchronous execution.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

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