Commit a2026b41 authored by owaits's avatar owaits
Browse files

Now handles values of none without throwing an exception. This bug could cause...

Now handles values of none without throwing an exception. This bug could cause images to load very slowly.
parent 90b1d42b
...@@ -23,6 +23,11 @@ namespace Svg ...@@ -23,6 +23,11 @@ namespace Svg
/// </summary> /// </summary>
public static readonly SvgUnit Empty = new SvgUnit(); public static readonly SvgUnit Empty = new SvgUnit();
/// <summary>
/// Gets an <see cref="SvgUnit"/> with a value of none.
/// </summary>
public static readonly SvgUnit None = new SvgUnit(SvgUnitType.None,0f);
/// <summary> /// <summary>
/// Gets a value to determine whether the unit is empty. /// Gets a value to determine whether the unit is empty.
/// </summary> /// </summary>
...@@ -179,6 +184,8 @@ namespace Svg ...@@ -179,6 +184,8 @@ namespace Svg
switch (this.Type) switch (this.Type)
{ {
case SvgUnitType.None:
return "none";
case SvgUnitType.Pixel: case SvgUnitType.Pixel:
type = "px"; type = "px";
break; break;
...@@ -256,6 +263,10 @@ namespace Svg ...@@ -256,6 +263,10 @@ namespace Svg
/// </summary> /// </summary>
public enum SvgUnitType public enum SvgUnitType
{ {
/// <summary>
/// Indicates that the unit holds no value.
/// </summary>
None,
/// <summary> /// <summary>
/// Indicates that the unit is in pixels. /// Indicates that the unit is in pixels.
/// </summary> /// </summary>
......
...@@ -39,7 +39,9 @@ namespace Svg ...@@ -39,7 +39,9 @@ namespace Svg
foreach (string point in points) foreach (string point in points)
{ {
units.Add((SvgUnit)_unitConverter.ConvertFrom(point.Trim())); SvgUnit newUnit = (SvgUnit)_unitConverter.ConvertFrom(point.Trim());
if(newUnit != SvgUnit.None)
units.Add(newUnit);
} }
return units; return units;
......
...@@ -29,6 +29,9 @@ namespace Svg ...@@ -29,6 +29,9 @@ namespace Svg
string unit = (string)value; string unit = (string)value;
int identifierIndex = -1; int identifierIndex = -1;
if (unit == "none")
return SvgUnit.None;
for (int i = 0; i < unit.Length; i++) for (int i = 0; i < unit.Length; i++)
{ {
if (char.IsLetter(unit[i]) || unit[i] == '%') if (char.IsLetter(unit[i]) || unit[i] == '%')
......
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