AngleSharp by AngleSharp

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

 SvgElementFactory

Provides string to SVGElement instance creation mappings.
using AngleSharp.Dom; using AngleSharp.Dom.Svg; using AngleSharp.Html; using System; using System.Collections.Generic; namespace AngleSharp.Services.Default { internal sealed class SvgElementFactory : ISvgElementFactory { private delegate SvgElement Creator (Document owner, string prefix); private readonly Dictionary<string, Creator> creators = new Dictionary<string, Creator>(StringComparer.OrdinalIgnoreCase) { { TagNames.Svg, (Document document, string prefix) => new SvgSvgElement(document, prefix) }, { TagNames.Circle, (Document document, string prefix) => new SvgCircleElement(document, prefix) }, { TagNames.Desc, (Document document, string prefix) => new SvgDescElement(document, prefix) }, { TagNames.ForeignObject, (Document document, string prefix) => new SvgForeignObjectElement(document, prefix) }, { TagNames.Title, (Document document, string prefix) => new SvgTitleElement(document, prefix) } }; public SvgElement Create(Document document, string localName, string prefix = null) { Creator value = null; if (creators.TryGetValue(localName, out value)) return value(document, prefix); return new SvgElement(document, localName, null, NodeFlags.None); } } }