1 | using System;
|
---|
2 | using System.Xml;
|
---|
3 | using System.Collections.Generic;
|
---|
4 |
|
---|
5 | namespace SharpVectors.Dom.Svg
|
---|
6 | {
|
---|
7 | public static class SvgElementFactory
|
---|
8 | {
|
---|
9 | public static XmlElement Create(string prefix, string localName,
|
---|
10 | string ns, SvgDocument doc)
|
---|
11 | {
|
---|
12 | // This factory assumes the requested element is defined in the
|
---|
13 | // http://www.w3.org/2000/svg namespace.
|
---|
14 | if (String.IsNullOrEmpty(ns) || !String.Equals(ns,
|
---|
15 | SvgDocument.SvgNamespace, StringComparison.OrdinalIgnoreCase))
|
---|
16 | {
|
---|
17 | return null;
|
---|
18 | }
|
---|
19 |
|
---|
20 | switch (localName)
|
---|
21 | {
|
---|
22 | case "a":
|
---|
23 | return new SvgAElement(prefix, localName, ns, doc);
|
---|
24 | case "circle":
|
---|
25 | return new SvgCircleElement(prefix, localName, ns, doc);
|
---|
26 | case "clipPath":
|
---|
27 | return new SvgClipPathElement(prefix, localName, ns, doc);
|
---|
28 | case "defs":
|
---|
29 | return new SvgDefsElement(prefix, localName, ns, doc);
|
---|
30 | case "desc":
|
---|
31 | return new SvgDescElement(prefix, localName, ns, doc);
|
---|
32 | case "ellipse":
|
---|
33 | return new SvgEllipseElement(prefix, localName, ns, doc);
|
---|
34 | case "g":
|
---|
35 | return new SvgGElement(prefix, localName, ns, doc);
|
---|
36 | case "image":
|
---|
37 | return new SvgImageElement(prefix, localName, ns, doc);
|
---|
38 | case "line":
|
---|
39 | return new SvgLineElement(prefix, localName, ns, doc);
|
---|
40 | case "linearGradient":
|
---|
41 | return new SvgLinearGradientElement(prefix, localName, ns, doc);
|
---|
42 | case "marker":
|
---|
43 | return new SvgMarkerElement(prefix, localName, ns, doc);
|
---|
44 | case "mask":
|
---|
45 | return new SvgMaskElement(prefix, localName, ns, doc);
|
---|
46 | case "metadata":
|
---|
47 | return new SvgMetadataElement(prefix, localName, ns, doc);
|
---|
48 | case "rect":
|
---|
49 | return new SvgRectElement(prefix, localName, ns, doc);
|
---|
50 | case "path":
|
---|
51 | return new SvgPathElement(prefix, localName, ns, doc);
|
---|
52 | case "pattern":
|
---|
53 | return new SvgPatternElement(prefix, localName, ns, doc);
|
---|
54 | case "polyline":
|
---|
55 | return new SvgPolylineElement(prefix, localName, ns, doc);
|
---|
56 | case "polygon":
|
---|
57 | return new SvgPolygonElement(prefix, localName, ns, doc);
|
---|
58 | case "radialGradient":
|
---|
59 | return new SvgRadialGradientElement(prefix, localName, ns, doc);
|
---|
60 | case "script":
|
---|
61 | return new SvgScriptElement(prefix, localName, ns, doc);
|
---|
62 | case "stop":
|
---|
63 | return new SvgStopElement(prefix, localName, ns, doc);
|
---|
64 | case "svg":
|
---|
65 | return new SvgSvgElement(prefix, localName, ns, doc);
|
---|
66 | case "switch":
|
---|
67 | return new SvgSwitchElement(prefix, localName, ns, doc);
|
---|
68 | case "symbol":
|
---|
69 | return new SvgSymbolElement(prefix, localName, ns, doc);
|
---|
70 | case "text":
|
---|
71 | return new SvgTextElement(prefix, localName, ns, doc);
|
---|
72 | case "textPath":
|
---|
73 | return new SvgTextPathElement(prefix, localName, ns, doc);
|
---|
74 | case "title":
|
---|
75 | return new SvgTitleElement(prefix, localName, ns, doc);
|
---|
76 | case "tref":
|
---|
77 | return new SvgTRefElement(prefix, localName, ns, doc);
|
---|
78 | case "tspan":
|
---|
79 | return new SvgTSpanElement(prefix, localName, ns, doc);
|
---|
80 | case "use":
|
---|
81 | return new SvgUseElement(prefix, localName, ns, doc);
|
---|
82 | case "color-profile":
|
---|
83 | return new SvgColorProfileElement(prefix, localName, ns, doc);
|
---|
84 | }
|
---|
85 |
|
---|
86 | return null;
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|