diff --git a/Source/Basic Shapes/SvgLine.cs b/Source/Basic Shapes/SvgLine.cs index 348c8a07d4d62fccaf0c5acbddcd204132625424..1ece3ee9ce991ca9dc99406a26ae8e8f5230a368 100644 --- a/Source/Basic Shapes/SvgLine.cs +++ b/Source/Basic Shapes/SvgLine.cs @@ -4,6 +4,7 @@ using System.Text; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; +using Svg.ExtensionMethods; namespace Svg { @@ -85,7 +86,7 @@ namespace Svg [SvgAttribute("marker-end")] public Uri MarkerEnd { - get { return this.Attributes.GetAttribute("marker-end"); } + get { return this.Attributes.GetAttribute("marker-end").ReplaceWithNullIfNone(); } set { this.Attributes["marker-end"] = value; } } @@ -96,7 +97,7 @@ namespace Svg [SvgAttribute("marker-mid")] public Uri MarkerMid { - get { return this.Attributes.GetAttribute("marker-mid"); } + get { return this.Attributes.GetAttribute("marker-mid").ReplaceWithNullIfNone(); } set { this.Attributes["marker-mid"] = value; } } @@ -107,7 +108,7 @@ namespace Svg [SvgAttribute("marker-start")] public Uri MarkerStart { - get { return this.Attributes.GetAttribute("marker-start"); } + get { return this.Attributes.GetAttribute("marker-start").ReplaceWithNullIfNone(); } set { this.Attributes["marker-start"] = value; } } diff --git a/Source/Basic Shapes/SvgPolygon.cs b/Source/Basic Shapes/SvgPolygon.cs index a59a32832cc7dc97cd2122e3f29d17c8327e396a..7eb427b59a156ce032297afafaebcca9fa61b1d9 100644 --- a/Source/Basic Shapes/SvgPolygon.cs +++ b/Source/Basic Shapes/SvgPolygon.cs @@ -4,6 +4,7 @@ using System.Text; using System.Drawing; using System.Drawing.Drawing2D; using System.Diagnostics; +using Svg.ExtensionMethods; using Svg.Pathing; namespace Svg @@ -32,7 +33,7 @@ namespace Svg [SvgAttribute("marker-end")] public Uri MarkerEnd { - get { return this.Attributes.GetAttribute("marker-end"); } + get { return this.Attributes.GetAttribute("marker-end").ReplaceWithNullIfNone(); } set { this.Attributes["marker-end"] = value; } } @@ -43,7 +44,7 @@ namespace Svg [SvgAttribute("marker-mid")] public Uri MarkerMid { - get { return this.Attributes.GetAttribute("marker-mid"); } + get { return this.Attributes.GetAttribute("marker-mid").ReplaceWithNullIfNone(); } set { this.Attributes["marker-mid"] = value; } } @@ -54,7 +55,7 @@ namespace Svg [SvgAttribute("marker-start")] public Uri MarkerStart { - get { return this.Attributes.GetAttribute("marker-start"); } + get { return this.Attributes.GetAttribute("marker-start").ReplaceWithNullIfNone(); } set { this.Attributes["marker-start"] = value; } } diff --git a/Source/Basic Shapes/SvgPolyline.cs b/Source/Basic Shapes/SvgPolyline.cs index 0aa692424a48b59f5c635c557c9416d537bccce2..650b8fad405f506490ecaaa5ae50de0067ee3cc0 100644 --- a/Source/Basic Shapes/SvgPolyline.cs +++ b/Source/Basic Shapes/SvgPolyline.cs @@ -4,6 +4,7 @@ using System.Text; using System.Drawing; using System.Drawing.Drawing2D; using System.Diagnostics; +using Svg.ExtensionMethods; namespace Svg { @@ -19,7 +20,7 @@ namespace Svg [SvgAttribute("marker-end")] public Uri MarkerEnd { - get { return this.Attributes.GetAttribute("marker-end"); } + get { return this.Attributes.GetAttribute("marker-end").ReplaceWithNullIfNone(); } set { this.Attributes["marker-end"] = value; } } @@ -30,7 +31,7 @@ namespace Svg [SvgAttribute("marker-mid")] public Uri MarkerMid { - get { return this.Attributes.GetAttribute("marker-mid"); } + get { return this.Attributes.GetAttribute("marker-mid").ReplaceWithNullIfNone(); } set { this.Attributes["marker-mid"] = value; } } @@ -41,7 +42,7 @@ namespace Svg [SvgAttribute("marker-start")] public Uri MarkerStart { - get { return this.Attributes.GetAttribute("marker-start"); } + get { return this.Attributes.GetAttribute("marker-start").ReplaceWithNullIfNone(); } set { this.Attributes["marker-start"] = value; } } diff --git a/Source/ExtensionMethods/UriExtensions.cs b/Source/ExtensionMethods/UriExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..aa300f9945471bc8e0b162032a90493aadded7a2 --- /dev/null +++ b/Source/ExtensionMethods/UriExtensions.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Svg.ExtensionMethods +{ + public static class UriExtensions + { + public static Uri ReplaceWithNullIfNone(this Uri uri) + { + if(uri == null) { return null; } + return string.Equals(uri.ToString(), "none", StringComparison.OrdinalIgnoreCase) ? null : uri; + } + } +} diff --git a/Source/Paths/SvgPath.cs b/Source/Paths/SvgPath.cs index 9d5c2ea837f44e769102846a8eb896f57b0c2b76..ce9e322413873f4fcf6a4e6acdf7fcad61382e91 100644 --- a/Source/Paths/SvgPath.cs +++ b/Source/Paths/SvgPath.cs @@ -6,6 +6,7 @@ using System.Drawing.Drawing2D; using System.Xml.Serialization; using System.Xml; using System.Diagnostics; +using Svg.ExtensionMethods; using Svg.Pathing; using Svg.Transforms; @@ -51,7 +52,7 @@ namespace Svg [SvgAttribute("marker-end", true)] public Uri MarkerEnd { - get { return this.Attributes.GetAttribute("marker-end"); } + get { return this.Attributes.GetAttribute("marker-end").ReplaceWithNullIfNone(); } set { this.Attributes["marker-end"] = value; } } @@ -62,7 +63,7 @@ namespace Svg [SvgAttribute("marker-mid", true)] public Uri MarkerMid { - get { return this.Attributes.GetAttribute("marker-mid"); } + get { return this.Attributes.GetAttribute("marker-mid").ReplaceWithNullIfNone(); } set { this.Attributes["marker-mid"] = value; } } @@ -73,7 +74,7 @@ namespace Svg [SvgAttribute("marker-start", true)] public Uri MarkerStart { - get { return this.Attributes.GetAttribute("marker-start"); } + get { return this.Attributes.GetAttribute("marker-start").ReplaceWithNullIfNone(); } set { this.Attributes["marker-start"] = value; } } diff --git a/Source/Svg.csproj b/Source/Svg.csproj index ea132a119e11395dd05e6a30dd2e8252005a1aa7..36f894f70f351798bb97b0a148bab1114f88281f 100644 --- a/Source/Svg.csproj +++ b/Source/Svg.csproj @@ -107,6 +107,7 @@ +