/// <summary> /// Creates an LinkRel provider for the provided element. /// </summary> /// <param name="link">The link element.</param> /// <param name="rel">The current value of the rel attribute.</param> /// <returns>The LinkRel provider instance or null.</returns> public BaseLinkRelation?Create(IHtmlLinkElement link, String?rel) { if (rel != null && _creators.TryGetValue(rel, out var creator)) { return(creator.Invoke(link)); } return(CreateDefault(link, rel)); }
static bool SameLink(IHtmlLinkElement m, LinkElement a) { return(m.Relation == a.Rel && ( (new[] { "canonical", "prev", "next" }.Contains(a.Rel)) || (a.Rel == "icon" && (m.Sizes?.ToString() ?? "") == a.Sizes) || (a.Rel == "alternate" && m.Type == a.Type && m.Media == a.Media) || (Href(m.Href) == a.Href) )); };
static bool SameLink(IHtmlLinkElement m, LinkElement a) { return(m.Relation == a.Rel && (a.Rel switch { "canonical" => true, "prev" => true, "next" => true, "icon" => (m.Sizes?.ToString() ?? "") == (a.Sizes ?? ""), "alternate" => (m.Type ?? "") == (a.Type ?? "") && (m.Media ?? "") == (a.Media ?? ""), "preload" => Href(m.Href) == (a.Href ?? "") && (m.Media ?? "") == (a.Media ?? ""), _ => Href(m.Href) == (a.Href ?? "") }));
/// <summary> /// Creates the default LinkRel provider for the given link element /// and relation. By default this is null. /// </summary> /// <param name="link">The link element.</param> /// <param name="rel">The current value of the rel attribute.</param> /// <returns>The LinkRel provider instance or null.</returns> protected virtual BaseLinkRelation?CreateDefault(IHtmlLinkElement link, String?rel) { return(default(BaseLinkRelation)); }
/// <summary> /// Creates a new instance of the relation processor. /// </summary> public BaseLinkRelation(IHtmlLinkElement link, IRequestProcessor processor) { _link = link; _processor = processor; }
public ImportLinkRelation(IHtmlLinkElement link) : base(link, new DocumentRequestProcessor(link?.Owner.Context)) { }
public StyleSheetLinkRelation(IHtmlLinkElement link) : base(link, new StyleSheetRequestProcessor(link?.Owner.Context, link)) { }