Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteAsyncInternal() [2/2]

async Task System.IO.StreamWriter.WriteAsyncInternal ( ReadOnlyMemory< char > source,
bool appendNewLine,
CancellationToken cancellationToken )
inlineprivate

Definition at line 664 of file StreamWriter.cs.

665 {
666 int num;
667 for (int copied = 0; copied < source.Length; copied += num)
668 {
669 if (_charPos == _charLen)
670 {
671 await FlushAsyncInternal(flushStream: false, flushEncoder: false, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
672 }
673 num = Math.Min(_charLen - _charPos, source.Length - copied);
674 ReadOnlySpan<char> readOnlySpan = source.Span;
675 readOnlySpan = readOnlySpan.Slice(copied, num);
676 readOnlySpan.CopyTo(new Span<char>(_charBuffer, _charPos, num));
677 _charPos += num;
678 }
679 if (appendNewLine)
680 {
681 for (int i = 0; i < CoreNewLine.Length; i++)
682 {
683 if (_charPos == _charLen)
684 {
685 await FlushAsyncInternal(flushStream: false, flushEncoder: false, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
686 }
688 }
689 }
690 if (_autoFlush)
691 {
692 await FlushAsyncInternal(flushStream: true, flushEncoder: false, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
693 }
694 }
readonly char[] _charBuffer
Task FlushAsyncInternal(bool flushStream, bool flushEncoder, CancellationToken cancellationToken=default(CancellationToken))

References System.IO.StreamWriter._autoFlush, System.IO.StreamWriter._charBuffer, System.IO.StreamWriter._charLen, System.IO.StreamWriter._charPos, System.cancellationToken, System.ReadOnlySpan< T >.CopyTo(), System.IO.TextWriter.CoreNewLine, System.IO.StreamWriter.FlushAsyncInternal(), System.Math.Min(), System.ReadOnlySpan< T >.Slice(), and System.source.