AngleSharp by Florian Rappl

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

 BaseTokenizer

abstract class BaseTokenizer : SourceManager
Common methods and variables of all tokenizers.
using AngleSharp.Extensions; using System; using System.Diagnostics; using System.Text; namespace AngleSharp.Parser { [DebuggerStepThrough] internal abstract class BaseTokenizer : SourceManager { protected readonly StringBuilder _stringBuffer; public event EventHandler<ParseErrorEventArgs> ErrorOccurred; public BaseTokenizer(TextSource source) : base(source) { _stringBuffer = Pool.NewStringBuilder(); } public TextPosition GetCurrentPosition() { return new TextPosition(base.Line, base.Column, base.Position); } public override void Dispose() { base.Dispose(); _stringBuffer.ToPool(); } public void RaiseErrorOccurred(ErrorCode code) { if (this.ErrorOccurred != null) { TextPosition currentPosition = GetCurrentPosition(); ParseErrorEventArgs e = new ParseErrorEventArgs(code.GetCode(), code.GetMessage(), currentPosition); this.ErrorOccurred(this, e); } } public void RaiseErrorOccurred(ParseErrorEventArgs args) { if (this.ErrorOccurred != null) this.ErrorOccurred(this, args); } } }