Skip to content

Commit 00fdaf0

Browse files
committed
fix #100
1 parent 0068338 commit 00fdaf0

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Source/SVGImage/SVG/Animation/AnimateTransform.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public sealed class AnimateTransform : AnimationBase
2222

2323
public AnimateTransform(SVG svg, XmlNode node, Shape parent)
2424
: base(svg, node, parent)
25-
{
26-
this.Type = (AnimateTransformType)Enum.Parse(typeof(AnimateTransformType),
27-
XmlUtil.AttrValue(node, "type", "translate"), true);
25+
{
26+
var valTranslate = XmlUtil.AttrValue(node, "type", "translate");
27+
if (Enum.TryParse<AnimateTransformType>(valTranslate, true, out var parsed))
28+
this.Type = parsed;
2829
this.From = XmlUtil.AttrValue(node, "from", null);
2930
this.To = XmlUtil.AttrValue(node, "to", null);
3031
this.AttributeName = XmlUtil.AttrValue(node, "attributeName", null);

Source/SVGImage/SVG/Shapes/Shape.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,14 @@ protected virtual void Parse(SVG svg, string name, string value)
252252
}
253253
if (name == SVGTags.sStrokeLinecap)
254254
{
255-
this.GetStroke(svg).LineCap = (Stroke.eLineCap)Enum.Parse(typeof(Stroke.eLineCap), value);
255+
if (Enum.TryParse<Stroke.eLineCap>(value, true, out var parsed))
256+
this.GetStroke(svg).LineCap = parsed;
256257
return;
257258
}
258259
if (name == SVGTags.sStrokeLinejoin)
259-
{
260-
this.GetStroke(svg).LineJoin = (Stroke.eLineJoin)Enum.Parse(typeof(Stroke.eLineJoin), value);
260+
{
261+
if (Enum.TryParse<Stroke.eLineJoin>(value, true, out var parsed))
262+
this.GetStroke(svg).LineJoin = parsed;
261263
return;
262264
}
263265
if (name == SVGTags.sFilterProperty)
@@ -302,8 +304,9 @@ protected virtual void Parse(SVG svg, string name, string value)
302304
return;
303305
}
304306
if (name == SVGTags.sFillRule)
305-
{
306-
this.GetFill(svg).FillRule = (Fill.eFillRule)Enum.Parse(typeof(Fill.eFillRule), value);
307+
{
308+
if (Enum.TryParse<Fill.eFillRule>(value, true, out var parsed))
309+
this.GetFill(svg).FillRule = parsed;
307310
return;
308311
}
309312
if (name == SVGTags.sOpacity)

0 commit comments

Comments
 (0)