Commit 77384831 authored by Gertjan van Heertum's avatar Gertjan van Heertum
Browse files

Extended the Marker start/mid/end getters with a function to return null if...

Extended the Marker start/mid/end getters with a function to return null if the property was set to none. This will prevent nullpointer issues when having none as one of the items.
parent bcf5b85c
Showing with 33 additions and 12 deletions
+33 -12
......@@ -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<Uri>("marker-end"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-mid"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-start"); }
get { return this.Attributes.GetAttribute<Uri>("marker-start").ReplaceWithNullIfNone(); }
set { this.Attributes["marker-start"] = value; }
}
......
......@@ -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<Uri>("marker-end"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-mid"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-start"); }
get { return this.Attributes.GetAttribute<Uri>("marker-start").ReplaceWithNullIfNone(); }
set { this.Attributes["marker-start"] = value; }
}
......
......@@ -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<Uri>("marker-end"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-mid"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-start"); }
get { return this.Attributes.GetAttribute<Uri>("marker-start").ReplaceWithNullIfNone(); }
set { this.Attributes["marker-start"] = value; }
}
......
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;
}
}
}
......@@ -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<Uri>("marker-end"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-mid"); }
get { return this.Attributes.GetAttribute<Uri>("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<Uri>("marker-start"); }
get { return this.Attributes.GetAttribute<Uri>("marker-start").ReplaceWithNullIfNone(); }
set { this.Attributes["marker-start"] = value; }
}
......
......@@ -107,6 +107,7 @@
<Compile Include="DataTypes\SvgTextPathSpacing.cs" />
<Compile Include="DataTypes\XmlSpaceHandling.cs" />
<Compile Include="Document Structure\SvgSymbol.cs" />
<Compile Include="ExtensionMethods\UriExtensions.cs" />
<Compile Include="Filter Effects\ImageBuffer.cs" />
<Compile Include="Painting\GenericBoundable.cs" />
<Compile Include="Painting\SvgFallbackPaintServer .cs" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment