Skip to content

Commit b1d2136

Browse files
committed
Fixed a bug related to converting to non-IConvertible types.
1 parent d4ab42d commit b1d2136

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

MathConverter/MathConverter.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,19 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
218218
return System.Convert.ChangeType(evaluatedValue, targetType.GetGenericArguments()[0]);
219219
}
220220

221-
return System.Convert.ChangeType(evaluatedValue, targetType);
221+
if ((targetType.IsClass && ReferenceEquals(evaluatedValue, null)) || (!ReferenceEquals(evaluatedValue, null) && targetType.IsAssignableFrom(evaluatedValue.GetType())))
222+
{
223+
return evaluatedValue;
224+
}
225+
else if (targetType is IConvertible)
226+
{
227+
return System.Convert.ChangeType(evaluatedValue, targetType);
228+
}
229+
else
230+
{
231+
// Welp, we can't convert this value... O well.
232+
return evaluatedValue;
233+
}
222234
}
223235
var value = x[0].Evaluate(values);
224236
if (value == null)

MathConverter/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.2.1.1")]
55-
[assembly: AssemblyFileVersion("1.2.1.1")]
54+
[assembly: AssemblyVersion("1.2.1.2")]
55+
[assembly: AssemblyFileVersion("1.2.1.2")]
5656

5757
[assembly: XmlnsPrefix("http://hexinnovation.com/math", "math")]
5858
[assembly: XmlnsDefinition("http://hexinnovation.com/math", "HexInnovation")]

0 commit comments

Comments
 (0)