Interface IAsyncBinaryReader
Providers a uniform way to decode the data from various sources such as streams, pipes, unmanaged memory etc.
Namespace: DotNext.IO
Assembly: DotNext.IO.dll
Syntax
public interface IAsyncBinaryReader
Properties
| Improve this Doc View SourceEmpty
Represents empty reader.
Declaration
static IAsyncBinaryReader Empty { get; }
Property Value
Type | Description |
---|---|
IAsyncBinaryReader |
Methods
| Improve this Doc View SourceCopyToAsync(IBufferWriter<Byte>, CancellationToken)
Copies the content to the specified buffer.
Declaration
virtual Task CopyToAsync(IBufferWriter<byte> writer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IBufferWriter<Byte> | writer | The buffer writer. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of this method. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
CopyToAsync(PipeWriter, CancellationToken)
Copies the content to the specified pipe writer.
Declaration
Task CopyToAsync(PipeWriter output, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
PipeWriter | output | The writer. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of this method. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
CopyToAsync(Stream, CancellationToken)
Copies the content to the specified stream.
Declaration
Task CopyToAsync(Stream output, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | output | The output stream receiving object content. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
CopyToAsync<TArg>(ReadOnlySpanAction<Byte, TArg>, TArg, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
virtual Task CopyToAsync<TArg>(ReadOnlySpanAction<byte, TArg> consumer, TArg arg, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
CopyToAsync<TArg>(Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask>, TArg, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
virtual Task CopyToAsync<TArg>(Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> consumer, TArg arg, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
Create(ReadOnlySequence<Byte>)
Creates default implementation of binary reader over sequence of bytes.
Declaration
static SequenceBinaryReader Create(ReadOnlySequence<byte> sequence)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySequence<Byte> | sequence | The sequence of bytes. |
Returns
Type | Description |
---|---|
SequenceBinaryReader | The binary reader for the sequence of bytes. |
Create(PipeReader)
Creates default implementation of binary reader for the specifed pipe reader.
Declaration
static IAsyncBinaryReader Create(PipeReader reader)
Parameters
Type | Name | Description |
---|---|---|
PipeReader | reader | The pipe reader. |
Returns
Type | Description |
---|---|
IAsyncBinaryReader | The binary reader. |
Remarks
It is recommended to use extension methods from PipeExtensions class for decoding data from the stream. This method is intended for situation when you need an object implementing IAsyncBinaryReader interface.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Create(Stream, Memory<Byte>)
Creates default implementation of binary reader for the stream.
Declaration
static IAsyncBinaryReader Create(Stream input, Memory<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The stream to be wrapped into the reader. |
Memory<Byte> | buffer | The buffer used for decoding data from the stream. |
Returns
Type | Description |
---|---|
IAsyncBinaryReader | The stream reader. |
Remarks
It is recommended to use extension methods from StreamExtensions class for decoding data from the stream. This method is intended for situation when you need an object implementing IAsyncBinaryReader interface.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
Create(ReadOnlyMemory<Byte>)
Creates default implementation of binary reader over contiguous memory block.
Declaration
static SequenceBinaryReader Create(ReadOnlyMemory<byte> memory)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyMemory<Byte> | memory | The block of memory. |
Returns
Type | Description |
---|---|
SequenceBinaryReader | The binary reader for the memory block. |
ReadAsync(Memory<Byte>, CancellationToken)
Reads the block of bytes.
Declaration
ValueTask ReadAsync(Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Memory<Byte> | output | The block of memory to fill. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing state of asynchronous execution. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ReadAsync<T>(CancellationToken)
Decodes the value of blittable type.
Declaration
ValueTask<T> ReadAsync<T>(CancellationToken token = default(CancellationToken))
where T : struct
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<T> | The decoded value. |
Type Parameters
Name | Description |
---|---|
T | The type of the result. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ReadByteAsync(StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Parses 8-bit unsigned integer from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<byte> ReadByteAsync(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 |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<Byte> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The number 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. |
ReadDateTimeAsync(StringLengthEncoding, DecodingContext, DateTimeStyles, IFormatProvider, CancellationToken)
Parses DateTime from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<DateTime> ReadDateTimeAsync(StringLengthEncoding lengthFormat, DecodingContext context, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTime> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The date/time 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. |
ReadDateTimeAsync(StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)
Parses DateTime from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<DateTime> ReadDateTimeAsync(StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTime> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The date/time 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. |
ReadDateTimeOffsetAsync(StringLengthEncoding, DecodingContext, DateTimeStyles, IFormatProvider, CancellationToken)
Parses DateTimeOffset from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(StringLengthEncoding lengthFormat, DecodingContext context, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTimeOffset> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The date/time 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. |
ReadDateTimeOffsetAsync(StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)
Parses DateTimeOffset from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTimeOffset> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The date/time 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. |
ReadDecimalAsync(StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Parses Decimal from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<decimal> ReadDecimalAsync(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 |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<Decimal> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The number 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. |
ReadDoubleAsync(StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Parses double-precision floating-point number from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<double> ReadDoubleAsync(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 |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<Double> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The number 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. |
ReadGuidAsync(StringLengthEncoding, DecodingContext, String, CancellationToken)
Parses Guid from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<Guid> ReadGuidAsync(StringLengthEncoding lengthFormat, DecodingContext context, string format, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
String | format | The expected format of GUID value. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<Guid> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | GUID 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. |
ReadGuidAsync(StringLengthEncoding, DecodingContext, CancellationToken)
Parses Guid from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<Guid> ReadGuidAsync(StringLengthEncoding lengthFormat, DecodingContext context, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<Guid> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | GUID 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. |
ReadInt16Async(StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Parses 16-bit signed integer from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<short> ReadInt16Async(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 |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<Int16> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The number 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. |
ReadInt16Async(Boolean, CancellationToken)
Decodes 16-bit signed integer using the specified endianness.
Declaration
virtual ValueTask<short> ReadInt16Async(bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
ReadInt32Async(StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Parses 32-bit signed integer from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<int> ReadInt32Async(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 |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<Int32> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The number 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. |
ReadInt32Async(Boolean, CancellationToken)
Decodes 32-bit signed integer using the specified endianness.
Declaration
virtual ValueTask<int> ReadInt32Async(bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
ReadInt64Async(StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Parses 64-bit signed integer from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<long> ReadInt64Async(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 |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<Int64> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The number 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. |
ReadInt64Async(Boolean, CancellationToken)
Decodes 64-bit signed integer using the specified endianness.
Declaration
virtual ValueTask<long> ReadInt64Async(bool littleEndian, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
ReadSingleAsync(StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Parses single-precision floating-point number from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<float> ReadSingleAsync(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 |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
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 the operation. |
Returns
Type | Description |
---|---|
ValueTask<Single> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The number 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. |
ReadStringAsync(StringLengthEncoding, DecodingContext, CancellationToken)
Decodes the string.
Declaration
ValueTask<string> ReadStringAsync(StringLengthEncoding lengthFormat, DecodingContext context, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<String> | The decoded string. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ArgumentOutOfRangeException |
|
ReadStringAsync(Int32, DecodingContext, CancellationToken)
Decodes the string.
Declaration
ValueTask<string> ReadStringAsync(int length, DecodingContext context, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | The length of the encoded string, in bytes. |
DecodingContext | context | The decoding context containing string characters encoding. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<String> | The decoded string. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ReadTimeSpanAsync(StringLengthEncoding, DecodingContext, IFormatProvider, CancellationToken)
Parses TimeSpan from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<TimeSpan> ReadTimeSpanAsync(StringLengthEncoding lengthFormat, DecodingContext context, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |
ReadTimeSpanAsync(StringLengthEncoding, DecodingContext, String[], TimeSpanStyles, IFormatProvider, CancellationToken)
Parses TimeSpan from its string representation encoded in the underlying stream.
Declaration
virtual ValueTask<TimeSpan> ReadTimeSpanAsync(StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, TimeSpanStyles style = TimeSpanStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
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. |