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
/// </summary>
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>
/// Gets a value to determine whether the unit is empty.
/// </summary>
......@@ -179,6 +184,8 @@ namespace Svg
switch (this.Type)
{
case SvgUnitType.None:
return "none";
case SvgUnitType.Pixel:
type = "px";
break;
......@@ -256,6 +263,10 @@ namespace Svg
/// </summary>
public enum SvgUnitType
{
/// <summary>
/// Indicates that the unit holds no value.
/// </summary>
None,
/// <summary>
/// Indicates that the unit is in pixels.
/// </summary>
......
......@@ -39,7 +39,9 @@ namespace Svg
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;
......
......@@ -29,6 +29,9 @@ namespace Svg
string unit = (string)value;
int identifierIndex = -1;
if (unit == "none")
return SvgUnit.None;
for (int i = 0; i < unit.Length; 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