public static GeometryData Parse(XElement xElement) { GeometryData res = null; switch (xElement.Name.LocalName) { case "path": res = new PathData(xElement); break; case "rect": res = new RectangleData(xElement); break; case "circle": res = new CircleData(xElement); break; case "ellipse": res = new EllipseData(xElement); break; case "line": res = new LineData(xElement); break; case "polyline": break; case "polygon": res = new PolygonData(xElement); break; } return res; }
public void PutGeometryDataReturnSvgFormattedXElement() { var geometry = new PathData { GeometryType = "path", Data = "M202.67,216.08V143h134.663l-0.003-94.08h64v167.16H202.67", Fill = "#6CA9E0", Stroke = "#52AC62" }; var element = geometry.ToSvg(); Assert.AreEqual(element.Attribute("d").Value, "M202.67,216.08V143h134.663l-0.003-94.08h64v167.16H202.67"); Assert.AreEqual(element.Attribute("fill").Value, "#6CA9E0"); Assert.AreEqual(element.Attribute("stroke").Value, "#52AC62"); Assert.AreEqual(element.Attribute("x").Value, "0"); Assert.AreEqual(element.Attribute("y").Value, "0"); }