AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="1.4.1-beta.505" />

 TextSource

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 stream. The underlying stream is used as an unknown data source.

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

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

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

public void Dispose()

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

Gets underlying text source.

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 string ReadCharacters(int characters)

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

public StringOrMemory ReadMemory(int characters)

public bool TryGetContentLength(out int length)

Gets the content length, if known.