Class StreamExtensions
Represents high-level read/write methods for the stream.
Inherited Members
Namespace: DotNext.IO
Assembly: DotNext.IO.dll
Syntax
public static class StreamExtensions
Remarks
This class provides alternative way to read and write typed data from/to the stream without instantiation of BinaryReader and BinaryWriter.
Methods
| Improve this Doc View SourceAsBufferWriter(Stream, Nullable<MemoryAllocator<Byte>>)
Converts the stream to IBufferWriter<T>.
Declaration
public static IFlushableBufferWriter<byte> AsBufferWriter(this Stream output, MemoryAllocator<byte>? allocator = default(MemoryAllocator<byte>? ))
Parameters
Type | Name | Description |
---|---|---|
Stream | output | The stream to convert. |
Nullable<MemoryAllocator<Byte>> | allocator | The allocator of the buffer. |
Returns
Type | Description |
---|---|
IFlushableBufferWriter<Byte> | The buffered stream writer. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
CopyTo(Stream, IBufferWriter<Byte>, Int32, CancellationToken)
Synchronously reads the bytes from the current stream and writes them to buffer writer, using a specified cancellation token.
Declaration
public static long CopyTo(this Stream source, IBufferWriter<byte> destination, int bufferSize = 0, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
IBufferWriter<Byte> | destination | The writer to which the contents of the current stream will be copied. |
Int32 | bufferSize | The size, in bytes, of the buffer. |
CancellationToken | token | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Int64 | The number of copied bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
NotSupportedException |
|
OperationCanceledException | The operation has been canceled. |
CopyTo(Stream, Stream, Span<Byte>, CancellationToken)
Synchronously reads the bytes from the source stream and writes them to another stream, using a specified buffer.
Declaration
public static long CopyTo(this Stream source, Stream destination, Span<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream to read from. |
Stream | destination | The destination stream to write into. |
Span<Byte> | buffer | The buffer used to hold copied content temporarily. |
CancellationToken | token | The token that can be used to cancel this operation. |
Returns
Type | Description |
---|---|
Int64 | The total number of copied bytes. |
CopyToAsync(Stream, IBufferWriter<Byte>, Int32, CancellationToken)
Asynchronously reads the bytes from the current stream and writes them to buffer writer, using a specified cancellation token.
Declaration
public static Task<long> CopyToAsync(this Stream source, IBufferWriter<byte> destination, int bufferSize = 0, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
IBufferWriter<Byte> | destination | The writer to which the contents of the current stream will be copied. |
Int32 | bufferSize | The size, in bytes, of the buffer. |
CancellationToken | token | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<Int64> | The number of copied bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
NotSupportedException |
|
OperationCanceledException | The operation has been canceled. |
CopyToAsync(Stream, Stream, Memory<Byte>, CancellationToken)
Asynchronously reads the bytes from the source stream and writes them to another stream, using a specified buffer.
Declaration
public static ValueTask<long> CopyToAsync(this Stream source, Stream destination, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream to read from. |
Stream | destination | The destination stream to write into. |
Memory<Byte> | buffer | The buffer used to hold copied content temporarily. |
CancellationToken | token | The token that can be used to cancel this operation. |
Returns
Type | Description |
---|---|
ValueTask<Int64> | The total number of copied bytes. |
Read<T>(Stream)
Deserializes the value type from the stream.
Declaration
public static T Read<T>(this Stream stream)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Returns
Type | Description |
---|---|
T | The value deserialized from the stream. |
Type Parameters
Name | Description |
---|---|
T | The value type to be deserialized. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
Read<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Int32, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
public static void Read<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, int bufferSize = 256, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
ReadOnlySpanAction<Byte, TArg> | reader | The content reader. |
TArg | arg | The argument to be passed to the content reader. |
Int32 | bufferSize | The size of the buffer used to read data. |
CancellationToken | token | The token that can be used to cancel operation. |
Type Parameters
Name | Description |
---|---|
TArg | The type of the argument to be passed to the content reader. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |
Read<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Span<Byte>, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
public static void Read<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, Span<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
ReadOnlySpanAction<Byte, TArg> | reader | The content reader. |
TArg | arg | The argument to be passed to the content reader. |
Span<Byte> | buffer | The buffer allocated by the caller. |
CancellationToken | token | The token that can be used to cancel operation. |
Type Parameters
Name | Description |
---|---|
TArg | The type of the argument to be passed to the content reader. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
OperationCanceledException | The operation has been canceled. |
ReadAsync<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Int32, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
public static Task ReadAsync<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, int bufferSize = 256, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
ReadOnlySpanAction<Byte, TArg> | reader | The content reader. |
TArg | arg | The argument to be passed to the content reader. |
Int32 | bufferSize | The size of the buffer used to read data. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of this method. |
Type Parameters
Name | Description |
---|---|
TArg | The type of the argument to be passed to the content reader. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |
ReadAsync<TArg>(Stream, ReadOnlySpanAction<Byte, TArg>, TArg, Memory<Byte>, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
public static Task ReadAsync<TArg>(this Stream stream, ReadOnlySpanAction<byte, TArg> reader, TArg arg, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
ReadOnlySpanAction<Byte, TArg> | reader | The content reader. |
TArg | arg | The argument to be passed to the content reader. |
Memory<Byte> | buffer | The buffer allocated by the caller. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of this method. |
Type Parameters
Name | Description |
---|---|
TArg | The type of the argument to be passed to the content reader. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
OperationCanceledException | The operation has been canceled. |
ReadAsync<TArg>(Stream, Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask>, TArg, Int32, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
public static Task ReadAsync<TArg>(this Stream stream, Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> reader, TArg arg, int bufferSize = 256, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask> | reader | The content reader. |
TArg | arg | The argument to be passed to the content reader. |
Int32 | bufferSize | The size of the buffer used to read data. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of this method. |
Type Parameters
Name | Description |
---|---|
TArg | The type of the argument to be passed to the content reader. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |
ReadAsync<TArg>(Stream, Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask>, TArg, Memory<Byte>, CancellationToken)
Reads the entire content using the specified delegate.
Declaration
public static Task ReadAsync<TArg>(this Stream stream, Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> reader, TArg arg, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Func<ReadOnlyMemory<Byte>, TArg, CancellationToken, ValueTask> | reader | The content reader. |
TArg | arg | The argument to be passed to the content reader. |
Memory<Byte> | buffer | The buffer allocated by the caller. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of this method. |
Type Parameters
Name | Description |
---|---|
TArg | The type of the argument to be passed to the content reader. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
OperationCanceledException | The operation has been canceled. |
ReadAsync<T>(Stream, Memory<Byte>, CancellationToken)
Asynchronously deserializes the value type from the stream.
Declaration
public static ValueTask<T> ReadAsync<T>(this Stream stream, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<T> | The value deserialized from the stream. |
Type Parameters
Name | Description |
---|---|
T | The value type to be deserialized. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
OperationCanceledException | The operation has been canceled. |
ReadAsync<T>(Stream, CancellationToken)
Asynchronously deserializes the value type from the stream.
Declaration
public static ValueTask<T> ReadAsync<T>(this Stream stream, CancellationToken token = default(CancellationToken))
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<T> | The value deserialized from the stream. |
Type Parameters
Name | Description |
---|---|
T | The value type to be deserialized. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
OperationCanceledException | The operation has been canceled. |
ReadBlock(Stream, Span<Byte>)
Reads exact number of bytes.
Declaration
public static void ReadBlock(this Stream stream, Span<byte> output)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Span<Byte> | output | A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
ReadBlockAsync(Stream, Memory<Byte>, CancellationToken)
Reads exact number of bytes asynchronously.
Declaration
public static ValueTask ReadBlockAsync(this Stream stream, Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Memory<Byte> | output | A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous execution of this method. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
OperationCanceledException | The operation has been canceled. |
ReadByte(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 8-bit unsigned integer from its string representation.
Declaration
public static byte ReadByte(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
Byte | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadByteAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 8-bit unsigned integer from its string representation.
Declaration
public static ValueTask<byte> ReadByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Byte> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadByteAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 8-bit unsigned integer from its string representation.
Declaration
public static ValueTask<byte> ReadByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Byte> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadBytes(Stream, Span<Byte>)
Reads exact number of bytes.
Declaration
[Obsolete("Use ReadBlock extension method instead")]
public static void ReadBytes(Stream stream, Span<byte> output)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Span<Byte> | output | A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
ReadBytesAsync(Stream, Memory<Byte>, CancellationToken)
Reads exact number of bytes asynchronously.
Declaration
[Obsolete("Use ReadBlockAsync extension method instead")]
public static ValueTask ReadBytesAsync(Stream stream, Memory<byte> output, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Memory<Byte> | output | A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous execution of this method. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
OperationCanceledException | The operation has been canceled. |
ReadDateTime(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, DateTimeStyles, IFormatProvider)
Decodes DateTime from its string representation.
Declaration
public static DateTime ReadDateTime(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
DateTime | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
ReadDateTime(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String[], DateTimeStyles, IFormatProvider)
Decodes DateTime from its string representation.
Declaration
public static DateTime ReadDateTime(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
String[] | formats | An array of allowable formats. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
DateTime | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTime from its string representation.
Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTime> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTime from its string representation.
Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTime> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTime from its string representation.
Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
String[] | formats | An array of allowable formats. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTime> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDateTimeAsync(Stream, StringLengthEncoding, DecodingContext, String[], Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTime from its string representation.
Declaration
public static ValueTask<DateTime> ReadDateTimeAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
String[] | formats | An array of allowable formats. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTime> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDateTimeOffset(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, DateTimeStyles, IFormatProvider)
Decodes DateTimeOffset from its string representation.
Declaration
public static DateTimeOffset ReadDateTimeOffset(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
DateTimeOffset | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
ReadDateTimeOffset(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String[], DateTimeStyles, IFormatProvider)
Decodes DateTimeOffset from its string representation.
Declaration
public static DateTimeOffset ReadDateTimeOffset(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
String[] | formats | An array of allowable formats. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
DateTimeOffset | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTimeOffset from its string representation.
Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTimeOffset> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTimeOffset from its string representation.
Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTimeOffset> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, String[], DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTimeOffset from its string representation.
Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
String[] | formats | An array of allowable formats. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTimeOffset> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDateTimeOffsetAsync(Stream, StringLengthEncoding, DecodingContext, String[], Memory<Byte>, DateTimeStyles, IFormatProvider, CancellationToken)
Decodes DateTimeOffset from its string representation.
Declaration
public static ValueTask<DateTimeOffset> ReadDateTimeOffsetAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, Memory<byte> buffer, DateTimeStyles style = DateTimeStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
String[] | formats | An array of allowable formats. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
DateTimeStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<DateTimeOffset> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The date/time string is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDecimal(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes Decimal from its string representation.
Declaration
public static decimal ReadDecimal(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingSign | NumberStyles.AllowTrailingWhite | NumberStyles.Integer | NumberStyles.Number, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
Decimal | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadDecimalAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes Decimal from its string representation.
Declaration
public static ValueTask<decimal> ReadDecimalAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingSign | NumberStyles.AllowTrailingWhite | NumberStyles.Integer | NumberStyles.Number, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Decimal> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDecimalAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes Decimal from its string representation.
Declaration
public static ValueTask<decimal> ReadDecimalAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingSign | NumberStyles.AllowTrailingWhite | NumberStyles.Integer | NumberStyles.Number, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Decimal> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDouble(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes double-precision floating-point number from its string representation.
Declaration
public static double ReadDouble(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
Double | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadDoubleAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes double-precision floating-point number from its string representation.
Declaration
public static ValueTask<double> ReadDoubleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Double> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadDoubleAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes double-precision floating-point number from its string representation.
Declaration
public static ValueTask<double> ReadDoubleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Double> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadGuid(Stream, StringLengthEncoding, DecodingContext, Span<Byte>)
Decodes Guid from its string representation.
Declaration
public static Guid ReadGuid(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
Returns
Type | Description |
---|---|
Guid | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | GUID value is in incorrect format. |
ReadGuid(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String)
Decodes Guid from its string representation.
Declaration
public static Guid ReadGuid(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string format)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The expected format of GUID value. |
Returns
Type | Description |
---|---|
Guid | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | GUID value is in incorrect format. |
ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, String, CancellationToken)
Decodes Guid from its string representation.
Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, string format, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The expected format of GUID value. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Guid> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | GUID value is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, CancellationToken)
Decodes Guid from its string representation.
Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Guid> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | GUID value is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, String, CancellationToken)
Decodes Guid from its string representation.
Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string format, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
String | format | The expected format of GUID value. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Guid> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | GUID value is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadGuidAsync(Stream, StringLengthEncoding, DecodingContext, CancellationToken)
Decodes Guid from its string representation.
Declaration
public static ValueTask<Guid> ReadGuidAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Guid> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | GUID value is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadInt16(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 16-bit signed integer from its string representation.
Declaration
public static short ReadInt16(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
Int16 | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadInt16Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 16-bit signed integer from its string representation.
Declaration
public static ValueTask<short> ReadInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Int16> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadInt16Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 16-bit signed integer from its string representation.
Declaration
public static ValueTask<short> ReadInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Int16> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadInt32(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 32-bit signed integer from its string representation.
Declaration
public static int ReadInt32(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
Int32 | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadInt32Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 32-bit signed integer from its string representation.
Declaration
public static ValueTask<int> ReadInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Int32> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadInt32Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 32-bit signed integer from its string representation.
Declaration
public static ValueTask<int> ReadInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Int32> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadInt64(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 64-bit signed integer from its string representation.
Declaration
public static long ReadInt64(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
Int64 | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadInt64Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 64-bit signed integer from its string representation.
Declaration
public static ValueTask<long> ReadInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Int64> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadInt64Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 64-bit signed integer from its string representation.
Declaration
public static ValueTask<long> ReadInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Int64> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadSByte(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 8-bit signed integer from its string representation.
Declaration
[CLSCompliant(false)]
public static sbyte ReadSByte(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
SByte | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadSByteAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 8-bit signed integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<sbyte> ReadSByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<SByte> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadSByteAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 8-bit signed integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<sbyte> ReadSByteAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<SByte> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadSingle(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes single-precision floating-point number from its string representation.
Declaration
public static float ReadSingle(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
Single | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadSingleAsync(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes single-precision floating-point number from its string representation.
Declaration
public static ValueTask<float> ReadSingleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Single> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadSingleAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes single-precision floating-point number from its string representation.
Declaration
public static ValueTask<float> ReadSingleAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowThousands | NumberStyles.AllowTrailingWhite | NumberStyles.Float | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<Single> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadString(Stream, StringLengthEncoding, DecodingContext, Span<Byte>)
Reads a length-prefixed string using the specified encoding and supplied reusable buffer.
Declaration
public static string ReadString(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
Returns
Type | Description |
---|---|
String | The string decoded from the log entry content stream. |
Remarks
This method decodes string length (in bytes) from stream in contrast to ReadString(Stream, Int32, DecodingContext, Span<Byte>).
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
ArgumentOutOfRangeException |
|
ReadString(Stream, StringLengthEncoding, Encoding)
Reads a length-prefixed string using the specified encoding.
Declaration
public static string ReadString(this Stream stream, StringLengthEncoding lengthFormat, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
Encoding | encoding | The encoding used to decode bytes from stream into characters. |
Returns
Type | Description |
---|---|
String | The string decoded from the log entry content stream. |
Remarks
This method decodes string length (in bytes) from stream in contrast to ReadString(Stream, Int32, Encoding).
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
ArgumentOutOfRangeException |
|
ReadString(Stream, Int32, DecodingContext, Span<Byte>)
Reads the string using the specified encoding and supplied reusable buffer.
Declaration
public static string ReadString(this Stream stream, int length, in DecodingContext context, Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Int32 | length | The length of the string, in bytes. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
Returns
Type | Description |
---|---|
String | The string decoded from the log entry content stream. |
Remarks
buffer
length can be less than length
but should be enough to decode at least one character of the specified encoding.
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
ReadString(Stream, Int32, Encoding)
Reads the string using the specified encoding.
Declaration
public static string ReadString(this Stream stream, int length, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Int32 | length | The length of the string, in bytes. |
Encoding | encoding | The encoding used to decode bytes from stream into characters. |
Returns
Type | Description |
---|---|
String | The string decoded from the log entry content stream. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
ReadStringAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, CancellationToken)
Reads a length-prefixed string asynchronously using the specified encoding and supplied reusable buffer.
Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<String> | The string decoded from the log entry content stream. |
Remarks
This method decodes string length (in bytes) from stream in contrast to ReadStringAsync(Stream, Int32, DecodingContext, Memory<Byte>, CancellationToken).
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
ReadStringAsync(Stream, StringLengthEncoding, Encoding, CancellationToken)
Reads a length-prefixed string asynchronously using the specified encoding and supplied reusable buffer.
Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, StringLengthEncoding lengthFormat, Encoding encoding, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
Encoding | encoding | The encoding used to decode bytes from stream into characters. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<String> | The string decoded from the log entry content stream. |
Remarks
This method decodes string length (in bytes) from stream in contrast to ReadStringAsync(Stream, Int32, Encoding, CancellationToken).
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
ReadStringAsync(Stream, Int32, DecodingContext, Memory<Byte>, CancellationToken)
Reads the string asynchronously using the specified encoding and supplied reusable buffer.
Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, int length, DecodingContext context, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Int32 | length | The length of the string, in bytes. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<String> | The string decoded from the log entry content stream. |
Remarks
buffer
length can be less than length
but should be enough to decode at least one character of the specified encoding.
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
OperationCanceledException | The operation has been canceled. |
ReadStringAsync(Stream, Int32, Encoding, CancellationToken)
Reads the string asynchronously using the specified encoding and supplied reusable buffer.
Declaration
public static ValueTask<string> ReadStringAsync(this Stream stream, int length, Encoding encoding, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
Int32 | length | The length of the string, in bytes. |
Encoding | encoding | The encoding used to decode bytes from stream into characters. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<String> | The string decoded from the log entry content stream. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
OperationCanceledException | The operation has been canceled. |
ReadTimeSpan(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, IFormatProvider)
Parses TimeSpan from its string representation encoded in the underlying stream.
Declaration
public static TimeSpan ReadTimeSpan(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
TimeSpan | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The time span is in incorrect format. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ReadTimeSpan(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, String[], TimeSpanStyles, IFormatProvider)
Parses DateTimeOffset from its string representation encoded in the underlying stream.
Declaration
public static TimeSpan ReadTimeSpan(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, string[] formats, TimeSpanStyles style = TimeSpanStyles.None, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
String[] | formats | An array of allowable formats. |
TimeSpanStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
TimeSpan | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The time span is in incorrect format. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ReadTimeSpanAsync(Stream, StringLengthEncoding, DecodingContext, IFormatProvider, CancellationToken)
Parses TimeSpan from its string representation encoded in the underlying stream.
Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TimeSpan> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The time span is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ReadTimeSpanAsync(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, IFormatProvider, CancellationToken)
Parses TimeSpan from its string representation encoded in the underlying stream.
Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TimeSpan> | The parsed value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
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(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, String[], TimeSpanStyles, IFormatProvider, CancellationToken)
Parses TimeSpan from its string representation encoded in the underlying stream.
Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, string[] formats, TimeSpanStyles style = TimeSpanStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String[] | formats | An array of allowable formats. |
TimeSpanStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TimeSpan> | The parsed value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
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(Stream, StringLengthEncoding, DecodingContext, String[], TimeSpanStyles, IFormatProvider, CancellationToken)
Parses TimeSpan from its string representation encoded in the underlying stream.
Declaration
public static ValueTask<TimeSpan> ReadTimeSpanAsync(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, string[] formats, TimeSpanStyles style = TimeSpanStyles.None, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The decoding context containing string characters encoding. |
String[] | formats | An array of allowable formats. |
TimeSpanStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TimeSpan> | The parsed value. |
Exceptions
Type | Condition |
---|---|
FormatException | The time span is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
EndOfStreamException | The underlying source doesn't contain necessary amount of bytes to decode the value. |
ReadUInt16(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 16-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ushort ReadUInt16(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
UInt16 | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadUInt16Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 16-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<ushort> ReadUInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<UInt16> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadUInt16Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 16-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<ushort> ReadUInt16Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<UInt16> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadUInt32(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 32-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static uint ReadUInt32(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
UInt32 | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadUInt32Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 32-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<uint> ReadUInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<UInt32> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadUInt32Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 32-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<uint> ReadUInt32Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<UInt32> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadUInt64(Stream, StringLengthEncoding, DecodingContext, Span<Byte>, NumberStyles, IFormatProvider)
Decodes 64-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ulong ReadUInt64(this Stream stream, StringLengthEncoding lengthFormat, in DecodingContext context, Span<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Span<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
UInt64 | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
ReadUInt64Async(Stream, StringLengthEncoding, DecodingContext, NumberStyles, IFormatProvider, CancellationToken)
Decodes 64-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<ulong> ReadUInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<UInt64> | The decoded value. |
Exceptions
Type | Condition |
---|---|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
ReadUInt64Async(Stream, StringLengthEncoding, DecodingContext, Memory<Byte>, NumberStyles, IFormatProvider, CancellationToken)
Decodes 64-bit unsigned integer from its string representation.
Declaration
[CLSCompliant(false)]
public static ValueTask<ulong> ReadUInt64Async(this Stream stream, StringLengthEncoding lengthFormat, DecodingContext context, Memory<byte> buffer, NumberStyles style = NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.Integer, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to read from. |
StringLengthEncoding | lengthFormat | The format of the string length encoded in the stream. |
DecodingContext | context | The text decoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
NumberStyles | style | A bitwise combination of the enumeration values that indicates the style elements. |
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask<UInt64> | The decoded value. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
EndOfStreamException | Unexpected end of stream. |
FormatException | The number is in incorrect format. |
OperationCanceledException | The operation has been canceled. |
Write(Stream, ReadOnlySequence<Byte>, CancellationToken)
Writes sequence of bytes to the underlying stream synchronously.
Declaration
public static void Write(this Stream stream, in ReadOnlySequence<byte> sequence, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
ReadOnlySequence<Byte> | sequence | The sequence of bytes. |
CancellationToken | token | The token that can be used to cancel the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
Write<T>(Stream, T)
Serializes value to the stream.
Declaration
public static void Write<T>(this Stream stream, in T value)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
T | value | The value to be written into the stream. |
Type Parameters
Name | Description |
---|---|
T | The value type to be serialized. |
WriteAsync(Stream, ReadOnlySequence<Byte>, CancellationToken)
Writes sequence of bytes to the underlying stream asynchronously.
Declaration
public static ValueTask WriteAsync(this Stream stream, ReadOnlySequence<byte> sequence, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
ReadOnlySequence<Byte> | sequence | The sequence of bytes. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous execution of this method. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
WriteAsync<T>(Stream, T, Memory<Byte>, CancellationToken)
Asynchronously serializes value to the stream.
Declaration
public static ValueTask WriteAsync<T>(this Stream stream, T value, Memory<byte> buffer, CancellationToken token = default(CancellationToken))
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
T | value | The value to be written into the stream. |
Memory<Byte> | buffer | The buffer that is used for serialization. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous execution of this method. |
Type Parameters
Name | Description |
---|---|
T | The value type to be serialized. |
WriteAsync<T>(Stream, T, CancellationToken)
Asynchronously serializes value to the stream.
Declaration
public static ValueTask WriteAsync<T>(this Stream stream, T value, CancellationToken token = default(CancellationToken))
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
T | value | The value to be written into the stream. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous execution of this method. |
Type Parameters
Name | Description |
---|---|
T | The value type to be serialized. |
WriteAsync<TArg>(Stream, Func<TArg, CancellationToken, ValueTask<ReadOnlyMemory<Byte>>>, TArg, CancellationToken)
Writes the memory blocks supplied by the specified delegate.
Declaration
public static Task<long> WriteAsync<TArg>(this Stream stream, Func<TArg, CancellationToken, ValueTask<ReadOnlyMemory<byte>>> supplier, TArg arg, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The destination stream. |
Func<TArg, CancellationToken, ValueTask<ReadOnlyMemory<Byte>>> | supplier | The delegate supplying memory blocks. |
TArg | arg | The argument to be passed to the supplier. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
Task<Int64> | The number of written bytes. |
Type Parameters
Name | Description |
---|---|
TArg | The type of the argument to be passed to the supplier. |
Remarks
Copy process will be stopped when supplier
returns empty ReadOnlyMemory<T>.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
WriteByte(Stream, Byte, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 8-bit unsigned integer as a string.
Declaration
public static void WriteByte(this Stream stream, byte value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Byte | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteByteAsync(Stream, Byte, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 8-bit unsigned integer as a string.
Declaration
public static ValueTask WriteByteAsync(this Stream stream, byte value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Byte | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteByteAsync(Stream, Byte, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 8-bit unsigned integer as a string.
Declaration
public static ValueTask WriteByteAsync(this Stream stream, byte value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Byte | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDateTime(Stream, DateTime, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes DateTime as a string.
Declaration
public static void WriteDateTime(this Stream stream, DateTime value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
DateTime | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteDateTimeAsync(Stream, DateTime, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes DateTime as a string.
Declaration
public static ValueTask WriteDateTimeAsync(this Stream stream, DateTime value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
DateTime | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDateTimeAsync(Stream, DateTime, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes DateTime as a string.
Declaration
public static ValueTask WriteDateTimeAsync(this Stream stream, DateTime value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
DateTime | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDateTimeOffset(Stream, DateTimeOffset, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes DateTimeOffset as a string.
Declaration
public static void WriteDateTimeOffset(this Stream stream, DateTimeOffset value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
DateTimeOffset | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteDateTimeOffsetAsync(Stream, DateTimeOffset, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes DateTimeOffset as a string.
Declaration
public static ValueTask WriteDateTimeOffsetAsync(this Stream stream, DateTimeOffset value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
DateTimeOffset | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDateTimeOffsetAsync(Stream, DateTimeOffset, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes DateTimeOffset as a string.
Declaration
public static ValueTask WriteDateTimeOffsetAsync(this Stream stream, DateTimeOffset value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
DateTimeOffset | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDecimal(Stream, Decimal, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes Decimal as a string.
Declaration
public static void WriteDecimal(this Stream stream, decimal value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Decimal | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteDecimalAsync(Stream, Decimal, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes double-precision floating-point number as a string.
Declaration
public static ValueTask WriteDecimalAsync(this Stream stream, decimal value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Decimal | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDecimalAsync(Stream, Decimal, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes double-precision floating-pointer number as a string.
Declaration
public static ValueTask WriteDecimalAsync(this Stream stream, decimal value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Decimal | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDouble(Stream, Double, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes double-precision floating-point number as a string.
Declaration
public static void WriteDouble(this Stream stream, double value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Double | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteDoubleAsync(Stream, Double, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes double-precision floating-point number as a string.
Declaration
public static ValueTask WriteDoubleAsync(this Stream stream, double value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Double | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteDoubleAsync(Stream, Double, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes double-precision floating-pointer number as a string.
Declaration
public static ValueTask WriteDoubleAsync(this Stream stream, double value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Double | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteGuid(Stream, Guid, StringLengthEncoding, Encoding, ReadOnlySpan<Char>)
Encodes Guid as a string.
Declaration
public static void WriteGuid(this Stream stream, Guid value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Guid | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
WriteGuidAsync(Stream, Guid, StringLengthEncoding, EncodingContext, Memory<Byte>, String, CancellationToken)
Encodes Guid as a string.
Declaration
public static ValueTask WriteGuidAsync(this Stream stream, Guid value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Guid | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteGuidAsync(Stream, Guid, StringLengthEncoding, EncodingContext, String, CancellationToken)
Encodes Guid as a string.
Declaration
public static ValueTask WriteGuidAsync(this Stream stream, Guid value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Guid | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteInt16(Stream, Int16, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 16-bit signed integer as a string.
Declaration
public static void WriteInt16(this Stream stream, short value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int16 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteInt16Async(Stream, Int16, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 16-bit signed integer as a string.
Declaration
public static ValueTask WriteInt16Async(this Stream stream, short value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int16 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteInt16Async(Stream, Int16, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 16-bit signed integer as a string.
Declaration
public static ValueTask WriteInt16Async(this Stream stream, short value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int16 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteInt32(Stream, Int32, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 32-bit signed integer as a string.
Declaration
public static void WriteInt32(this Stream stream, int value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int32 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteInt32Async(Stream, Int32, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 32-bit signed integer as a string.
Declaration
public static ValueTask WriteInt32Async(this Stream stream, int value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int32 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteInt32Async(Stream, Int32, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 16-bit signed integer as a string.
Declaration
public static ValueTask WriteInt32Async(this Stream stream, int value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int32 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteInt64(Stream, Int64, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 64-bit signed integer as a string.
Declaration
public static void WriteInt64(this Stream stream, long value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int64 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteInt64Async(Stream, Int64, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 64-bit signed integer as a string.
Declaration
public static ValueTask WriteInt64Async(this Stream stream, long value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int64 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteInt64Async(Stream, Int64, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 64-bit signed integer as a string.
Declaration
public static ValueTask WriteInt64Async(this Stream stream, long value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Int64 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteSByte(Stream, SByte, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 8-bit signed integer as a string.
Declaration
[CLSCompliant(false)]
public static void WriteSByte(this Stream stream, sbyte value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
SByte | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteSByteAsync(Stream, SByte, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 8-bit signed integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteSByteAsync(this Stream stream, sbyte value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
SByte | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteSByteAsync(Stream, SByte, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 8-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteSByteAsync(this Stream stream, sbyte value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
SByte | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteSingle(Stream, Single, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes single-precision floating-point number as a string.
Declaration
public static void WriteSingle(this Stream stream, float value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Single | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteSingleAsync(Stream, Single, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes single-precision floating-point number as a string.
Declaration
public static ValueTask WriteSingleAsync(this Stream stream, float value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Single | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteSingleAsync(Stream, Single, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes single-precision floating-pointer number as a string.
Declaration
public static ValueTask WriteSingleAsync(this Stream stream, float value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
Single | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteString(Stream, ReadOnlySpan<Char>, EncodingContext, Span<Byte>, Nullable<StringLengthEncoding>)
Writes a length-prefixed or raw string to the stream using supplied reusable buffer.
Declaration
public static void WriteString(this Stream stream, ReadOnlySpan<char> value, in EncodingContext context, Span<byte> buffer, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
ReadOnlySpan<Char> | value | The string to be encoded. |
EncodingContext | context | The encoding. |
Span<Byte> | buffer | The buffer allocated by the caller needed for characters encoding. |
Nullable<StringLengthEncoding> | lengthFormat | String length encoding format; or null to prevent encoding of string length. |
Remarks
This method doesn't encode the length of the string.
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentOutOfRangeException |
|
WriteString(Stream, ReadOnlySpan<Char>, Encoding, Nullable<StringLengthEncoding>)
Writes a length-prefixed or raw string to the stream.
Declaration
public static void WriteString(this Stream stream, ReadOnlySpan<char> value, Encoding encoding, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
ReadOnlySpan<Char> | value | The string to be encoded. |
Encoding | encoding | The string encoding. |
Nullable<StringLengthEncoding> | lengthFormat | String length encoding format; or null to prevent encoding of string length. |
Remarks
This method doesn't encode the length of the string.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
WriteStringAsync(Stream, ReadOnlyMemory<Char>, EncodingContext, Memory<Byte>, Nullable<StringLengthEncoding>, CancellationToken)
Writes a length-prefixed or raw string to the stream asynchronously using supplied reusable buffer.
Declaration
public static ValueTask WriteStringAsync(this Stream stream, ReadOnlyMemory<char> value, EncodingContext context, Memory<byte> buffer, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ), CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
ReadOnlyMemory<Char> | value | The string to be encoded. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer allocated by the caller needed for characters encoding. |
Nullable<StringLengthEncoding> | lengthFormat | String length encoding format; or null to prevent encoding of string length. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Remarks
This method doesn't encode the length of the string.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentException |
|
ArgumentOutOfRangeException |
|
WriteStringAsync(Stream, ReadOnlyMemory<Char>, Encoding, Nullable<StringLengthEncoding>, CancellationToken)
Writes a length-prefixed or raw string to the stream asynchronously.
Declaration
public static ValueTask WriteStringAsync(this Stream stream, ReadOnlyMemory<char> value, Encoding encoding, StringLengthEncoding? lengthFormat = default(StringLengthEncoding? ), CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
ReadOnlyMemory<Char> | value | The string to be encoded. |
Encoding | encoding | The encoding context. |
Nullable<StringLengthEncoding> | lengthFormat | Represents string length encoding format. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Remarks
This method doesn't encode the length of the string.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteTimeSpan(Stream, TimeSpan, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes TimeSpan as a string.
Declaration
public static void WriteTimeSpan(this Stream stream, TimeSpan value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
TimeSpan | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteTimeSpanAsync(Stream, TimeSpan, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes TimeSpan as a string.
Declaration
public static ValueTask WriteTimeSpanAsync(this Stream stream, TimeSpan value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
TimeSpan | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteTimeSpanAsync(Stream, TimeSpan, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes TimeSpan as a string.
Declaration
public static ValueTask WriteTimeSpanAsync(this Stream stream, TimeSpan value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
TimeSpan | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteUInt16(Stream, UInt16, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 16-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static void WriteUInt16(this Stream stream, ushort value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt16 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteUInt16Async(Stream, UInt16, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 16-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt16Async(this Stream stream, ushort value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt16 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteUInt16Async(Stream, UInt16, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 16-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt16Async(this Stream stream, ushort value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt16 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteUInt32(Stream, UInt32, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 32-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static void WriteUInt32(this Stream stream, uint value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt32 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteUInt32Async(Stream, UInt32, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 32-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt32Async(this Stream stream, uint value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt32 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteUInt32Async(Stream, UInt32, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 16-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt32Async(this Stream stream, uint value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt32 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteUInt64(Stream, UInt64, StringLengthEncoding, Encoding, ReadOnlySpan<Char>, IFormatProvider)
Encodes 64-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static void WriteUInt64(this Stream stream, ulong value, StringLengthEncoding lengthFormat, Encoding encoding, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider provider = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt64 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
Encoding | encoding | The string encoding. |
ReadOnlySpan<Char> | format | A span containing the characters that represent a standard or custom format string. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
WriteUInt64Async(Stream, UInt64, StringLengthEncoding, EncodingContext, Memory<Byte>, String, IFormatProvider, CancellationToken)
Encodes 64-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt64Async(this Stream stream, ulong value, StringLengthEncoding lengthFormat, EncodingContext context, Memory<byte> buffer, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt64 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
Memory<Byte> | buffer | The buffer that is allocated by the caller. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|
WriteUInt64Async(Stream, UInt64, StringLengthEncoding, EncodingContext, String, IFormatProvider, CancellationToken)
Encodes 64-bit unsigned integer as a string.
Declaration
[CLSCompliant(false)]
public static ValueTask WriteUInt64Async(this Stream stream, ulong value, StringLengthEncoding lengthFormat, EncodingContext context, string format = null, IFormatProvider provider = null, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write into. |
UInt64 | value | The value to encode. |
StringLengthEncoding | lengthFormat | String length encoding format. |
EncodingContext | context | The encoding context. |
String | format | The format to use. |
IFormatProvider | provider | An optional object that supplies culture-specific formatting information. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous state of the operation. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ArgumentOutOfRangeException |
|