81 protected override void Dispose(
bool disposing)
86 if (arraySegment.
Count != 0)
106 if (pendingData2.
Count == 0)
116 return DisposeAsyncCore(pendingData2);
139 [MemberNotNull(
new string[] {
"_innerDecoder",
"_thisEncoder",
"_readBuffer" })]
145 InitializeReadDataStructures();
147 void InitializeReadDataStructures()
160 [MemberNotNull(
new string[] {
"_thisDecoder",
"_innerEncoder" })]
166 InitializeReadDataStructures();
168 void InitializeReadDataStructures()
189 chars =
new char[num];
196 array =
new byte[num2];
238 while (!flag &&
bytes == 0);
286 while (!flag &&
bytes == 0);
367 _innerEncoder.
Convert(span, array2, flush:
false, out var charsUsed2, out var bytesUsed2, out completed2);
368 span = span.
Slice(charsUsed2);
402 int minimumLength =
Math.
Clamp(remainingOuterEncodedBytes.
Length, 4096, 1048576);
407 bool decoderFinished;
410 _thisDecoder.
Convert(remainingOuterEncodedBytes.
Span, scratchChars, flush:
false, out var bytesUsed, out var charsUsed, out decoderFinished);
411 remainingOuterEncodedBytes = remainingOuterEncodedBytes.
Slice(bytesUsed);
413 bool encoderFinished;
416 _innerEncoder.
Convert(decodedChars, scratchBytes, flush:
false, out var charsUsed2, out var bytesUsed2, out encoderFinished);
417 decodedChars = decodedChars.
Slice(charsUsed2);
420 while (!encoderFinished);
422 while (!decoderFinished);
static ArrayPool< T > Shared
static void ValidateBufferArguments(byte[] buffer, int offset, int count)
Task WriteAsync(byte[] buffer, int offset, int count)
int Read(byte[] buffer, int offset, int count)
Task< int > ReadAsync(byte[] buffer, int offset, int count)
void Write(byte[] buffer, int offset, int count)
virtual ValueTask DisposeAsync()
static byte Clamp(byte value, byte min, byte max)
static byte Min(byte val1, byte val2)
static string NotSupported_UnseekableStream
virtual void Convert(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
int GetCharCount(byte[] bytes, int index, int count)
int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
virtual void Convert(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
int GetByteCount(char[] chars, int index, int count, bool flush)
int GetMaxCharCount(int byteCount)
int GetMaxByteCount(int charCount)
virtual Decoder GetDecoder()
virtual Encoder GetEncoder()
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
override int Read(byte[] buffer, int offset, int count)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
unsafe override int ReadByte()
override int Read(Span< byte > buffer)
override Task FlushAsync(CancellationToken cancellationToken)
TranscodingStream(Stream innerStream, Encoding innerEncoding, Encoding thisEncoding, bool leaveOpen)
override void EndWrite(IAsyncResult asyncResult)
override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
void EnsurePreWriteConditions()
override ValueTask DisposeAsync()
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
void EnsurePreReadConditions()
ArraySegment< byte > FinalFlushWriteBuffers()
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken)
void ThrowObjectDisposedException()
int _readCharBufferMaxSize
readonly Encoding _thisEncoding
override void Write(byte[] buffer, int offset, int count)
unsafe override void WriteByte(byte value)
override void Write(ReadOnlySpan< byte > buffer)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken)
override int EndRead(IAsyncResult asyncResult)
override void SetLength(long value)
readonly Encoding _innerEncoding
override long Seek(long offset, SeekOrigin origin)
override void Dispose(bool disposing)
static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
static void End(IAsyncResult asyncResult)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
static void ThrowNotSupportedException_UnwritableStream()
static void ThrowNotSupportedException_UnseekableStream()
static void ThrowObjectDisposedException_StreamClosed(string objectName)
static void ThrowNotSupportedException_UnreadableStream()
ArraySegment< T > Slice(int index)
unsafe ReadOnlySpan< T > Span
ReadOnlyMemory< T > Slice(int start)
Span< T > Slice(int start)
static CancellationToken None
static ValueTask CompletedTask
static ValueTask FromCanceled(CancellationToken cancellationToken)
ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)