This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoreFx #22406 Span based APIs - Text Reader Writer
- Loading branch information
Showing
14 changed files
with
1,261 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.IO.Tests | ||
{ | ||
public class CharArrayTextReader : TextReader | ||
{ | ||
private readonly char[] _charBuffer; | ||
private int _charPos = 0; | ||
|
||
public bool EndOfStream => _charPos >= _charBuffer.Length; | ||
|
||
public CharArrayTextReader(char[] data) | ||
{ | ||
_charBuffer = data; | ||
} | ||
|
||
public override int Peek() | ||
{ | ||
if (_charPos == _charBuffer.Length) | ||
{ | ||
return -1; | ||
} | ||
return _charBuffer[_charPos]; | ||
} | ||
|
||
public override int Read() | ||
{ | ||
if (_charPos == _charBuffer.Length) | ||
{ | ||
return -1; | ||
} | ||
return _charBuffer[_charPos++]; | ||
} | ||
} | ||
} |
Oops, something went wrong.