AngleSharp by AngleSharp

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

 BrowsingContext

A simple and lightweight browsing context.
using AngleSharp.Dom; using AngleSharp.Extensions; using AngleSharp.Html; using AngleSharp.Network; using System; namespace AngleSharp { public sealed class BrowsingContext : EventTarget, IBrowsingContext, IEventTarget, IDisposable { private readonly IConfiguration _configuration; private readonly Sandboxes _security; private readonly IBrowsingContext _parent; private readonly IDocument _creator; private readonly IDocumentLoader _loader; private readonly IHistory _history; public IDocument Active { get; set; } public IDocumentLoader Loader => _loader; public IConfiguration Configuration => _configuration; public IDocument Creator => _creator; public IWindow Current => Active?.DefaultView; public IBrowsingContext Parent => _parent; public IHistory SessionHistory => _history; public Sandboxes Security => _security; event DomEventHandler IBrowsingContext.Parsing { add { AddEventListener(EventNames.ParseStart, value, false); } remove { RemoveEventListener(EventNames.ParseStart, value, false); } } event DomEventHandler IBrowsingContext.Parsed { add { AddEventListener(EventNames.ParseEnd, value, false); } remove { RemoveEventListener(EventNames.ParseEnd, value, false); } } event DomEventHandler IBrowsingContext.Requesting { add { AddEventListener(EventNames.RequestStart, value, false); } remove { RemoveEventListener(EventNames.RequestStart, value, false); } } event DomEventHandler IBrowsingContext.Requested { add { AddEventListener(EventNames.RequestEnd, value, false); } remove { RemoveEventListener(EventNames.RequestEnd, value, false); } } event DomEventHandler IBrowsingContext.ParseError { add { AddEventListener(EventNames.ParseError, value, false); } remove { RemoveEventListener(EventNames.ParseError, value, false); } } internal BrowsingContext(IConfiguration configuration, Sandboxes security) { _configuration = configuration; _security = security; _loader = this.CreateService<IDocumentLoader>(); _history = this.CreateService<IHistory>(); } internal BrowsingContext(IBrowsingContext parent, Sandboxes security) : this(parent.Configuration, security) { _parent = parent; _creator = _parent.Active; } public static IBrowsingContext New(IConfiguration configuration = null) { if (configuration == null) configuration = AngleSharp.Configuration.Default; return configuration.NewContext(Sandboxes.None); } void IDisposable.Dispose() { Active?.Dispose(); Active = null; } } }