|
@@ -1,4 +1,5 @@
|
|
|
using System.Globalization;
|
|
|
+using System.Reflection;
|
|
|
using System.Xml;
|
|
|
using System.Xml.Linq;
|
|
|
using Drawie.Numerics;
|
|
@@ -10,24 +11,10 @@ namespace PixiEditor.SVG;
|
|
|
|
|
|
public class SvgParser
|
|
|
{
|
|
|
- private static Dictionary<string, Type> wellKnownElements = new()
|
|
|
- {
|
|
|
- { "ellipse", typeof(SvgEllipse) },
|
|
|
- { "rect", typeof(SvgRectangle) },
|
|
|
- { "circle", typeof(SvgCircle) },
|
|
|
- { "line", typeof(SvgLine) },
|
|
|
- { "path", typeof(SvgPath) },
|
|
|
- { "g", typeof(SvgGroup) },
|
|
|
- { "mask", typeof(SvgMask) },
|
|
|
- { "image", typeof(SvgImage) },
|
|
|
- { "svg", typeof(SvgDocument) },
|
|
|
- { "text", typeof(SvgText) },
|
|
|
- { "linearGradient", typeof(SvgLinearGradient) },
|
|
|
- { "radialGradient", typeof(SvgRadialGradient) },
|
|
|
- { "stop", typeof(SvgStop) },
|
|
|
- { "defs", typeof(SvgDefs) },
|
|
|
- { "clipPath", typeof(SvgClipPath) }
|
|
|
- };
|
|
|
+ private static Dictionary<string, Type> wellKnownElements = Assembly.GetExecutingAssembly()
|
|
|
+ .GetTypes()
|
|
|
+ .Where(t => t.IsSubclassOf(typeof(SvgElement)) && !t.IsAbstract)
|
|
|
+ .ToDictionary(t => (Activator.CreateInstance(t) as SvgElement).TagName, t => t);
|
|
|
|
|
|
public string Source { get; set; }
|
|
|
|