Advanced constructor parameter binding on .NET Core & portable

This commit is contained in:
Alexey Skalozub
2016-09-01 04:31:43 +03:00
parent fac72ad50c
commit 95a4979ba4
4 changed files with 559 additions and 38 deletions
@@ -360,6 +360,13 @@ namespace Newtonsoft.Json.Utilities
return expression;
}
if (targetType.IsPrimitive())
{
expression = Expression.Call(
typeof(Convert).GetMethod("ChangeType", new[] { typeof(object), typeof(Type) }),
expression, Expression.Constant(targetType));
}
return Expression.Convert(expression, targetType);
}
}