AngleSharp by AngleSharp

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

 AttributeSelectorFactory

Provides string to CSS attribute selector instance mappings.
using AngleSharp.Css; using AngleSharp.Dom.Css; using System.Collections.Generic; namespace AngleSharp.Services.Default { public class AttributeSelectorFactory : IAttributeSelectorFactory { public delegate ISelector Creator (string name, string value, string prefix); private readonly Dictionary<string, Creator> _creators = new Dictionary<string, Creator> { { CombinatorSymbols.Exactly, SimpleSelector.AttrMatch }, { CombinatorSymbols.InList, SimpleSelector.AttrList }, { CombinatorSymbols.InToken, SimpleSelector.AttrHyphen }, { CombinatorSymbols.Begins, SimpleSelector.AttrBegins }, { CombinatorSymbols.Ends, SimpleSelector.AttrEnds }, { CombinatorSymbols.InText, SimpleSelector.AttrContains }, { CombinatorSymbols.Unlike, SimpleSelector.AttrNotMatch } }; public void Register(string combinator, Creator creator) { _creators.Add(combinator, creator); } public Creator Unregister(string combinator) { Creator value = null; if (_creators.TryGetValue(combinator, out value)) _creators.Remove(combinator); return value; } protected virtual ISelector CreateDefault(string name, string value, string prefix) { return SimpleSelector.AttrAvailable(name, value); } public ISelector Create(string combinator, string name, string value, string prefix) { Creator value2 = null; if (_creators.TryGetValue(combinator, out value2)) return value2(name, value, prefix); return CreateDefault(name, value, prefix); } } }