AngleSharp by AngleSharp

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

.NET API 1,232,384 bytes

 HtmlEmbedElement

Represents the embed element.
using AngleSharp.Dom.Css; using AngleSharp.Extensions; using AngleSharp.Html; using AngleSharp.Network; using AngleSharp.Services.Media; using System.Threading.Tasks; namespace AngleSharp.Dom.Html { internal sealed class HtmlEmbedElement : HtmlElement, IHtmlEmbedElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle { private IObjectInfo _obj; private IDownload _download; public string Source { get { return this.GetOwnAttribute(AttributeNames.Src); } set { this.SetOwnAttribute(AttributeNames.Src, value); } } public string Type { get { return this.GetOwnAttribute(AttributeNames.Type); } set { this.SetOwnAttribute(AttributeNames.Type, value); } } public string DisplayWidth { get { return this.GetOwnAttribute(AttributeNames.Width); } set { this.SetOwnAttribute(AttributeNames.Width, value); } } public string DisplayHeight { get { return this.GetOwnAttribute(AttributeNames.Height); } set { this.SetOwnAttribute(AttributeNames.Height, value); } } public HtmlEmbedElement(Document owner, string prefix = null) : base(owner, TagNames.Embed, prefix, NodeFlags.SelfClosing | NodeFlags.Special) { } internal override void SetupElement() { base.SetupElement(); string ownAttribute = this.GetOwnAttribute(AttributeNames.Src); RegisterAttributeObserver(AttributeNames.Src, UpdateSource); if (ownAttribute != null) UpdateSource(ownAttribute); } private void UpdateSource(string value) { if (_download != null) _download.Cancel(); Document owner = base.Owner; if (!string.IsNullOrEmpty(value) && owner != null) { IResourceLoader loader = owner.Loader; if (loader != null) { Url url = new Url(Source); ResourceRequest request = this.CreateRequestFor(url); IDownload download = loader.DownloadAsync(request); Task<bool> task = this.ProcessResource(download, delegate(IObjectInfo result) { _obj = result; }); owner.DelayLoad(task); _download = download; } } } } }