Skip to content

Commit d4ab42d

Browse files
committed
Added support for converting to Uri using a ConverterParameter
1 parent cb513fa commit d4ab42d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

MathConverter/MathConverter.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
153153
default:
154154
throw new NotSupportedException(string.Format("You supplied {0} values; string supports only one", x.Length));
155155
}
156+
case "System.Uri":
157+
switch (x.Length)
158+
{
159+
case 1:
160+
var val = x[0].Evaluate(values);
161+
if (val is string)
162+
return new Uri(val as string);
163+
else if (val == null)
164+
return null;
165+
else
166+
return new Uri(val.ToString());
167+
default:
168+
throw new NotSupportedException($"You supplied {values.Length} values; Uri supports only one");
169+
}
170+
156171
case "System.Single":
157172
convert = p => System.Convert.ToSingle(p);
158173
break;

0 commit comments

Comments
 (0)