AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="0.9.7" />

 TextSource

public sealed class TextSource : IDisposable
A stream abstraction to handle encoding and more.
public Encoding CurrentEncoding { get; set; }

Gets or sets the encoding to use.

public int Index { get; set; }

Gets or sets the current index of the insertation and read point.

public char this[int index] { get; }

Gets the character at the given position in the text buffer.

public int Length { get; }

Gets the length of the text buffer.

public string Text { get; }

Gets the full text buffer.

public TextSource(string source)

Creates a new text source from a string. No underlying stream will be used.

public TextSource(Stream baseStream, Encoding encoding = null)

Creates a new text source from a string. The underlying stream is used as an unknown data source.

public void Dispose()

Disposes the text source by freeing the underlying stream, if any.

public void InsertText(string content)

Inserts the given content at the current insertation mark. Moves the insertation mark.

public Task PrefetchAllAsync(CancellationToken cancellationToken)

Prefetches the whole stream by expanding the internal buffer.

public Task PrefetchAsync(int length, CancellationToken cancellationToken)

Prefetches the number of bytes by expanding the internal buffer.

public char ReadCharacter()

Reads the next character from the buffer or underlying stream, if any.

public Task<char> ReadCharacterAsync(CancellationToken cancellationToken)

Reads the next character from the buffer or underlying stream asynchronously, if any.

public string ReadCharacters(int characters)

Reads the upcoming numbers of characters from the buffer or underlying stream, if any.

public Task<string> ReadCharactersAsync(int characters, CancellationToken cancellationToken)

Reads the upcoming numbers of characters from the buffer or underlying stream asynchronously.