-Fixed WinRT build

This commit is contained in:
James Newton-King
2013-04-25 13:35:26 +12:00
parent 405de98daf
commit 2004377f3e
8 changed files with 84 additions and 65 deletions
@@ -96,16 +96,25 @@ namespace Newtonsoft.Json.Utilities
if (type.IsAbstract())
return () => (T)Activator.CreateInstance(type);
Type resultType = typeof(T);
try
{
Type resultType = typeof(T);
Expression expression = Expression.New(type);
Expression expression = Expression.New(type);
expression = EnsureCastExpression(expression, resultType);
expression = EnsureCastExpression(expression, resultType);
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func<T>), expression);
LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func<T>), expression);
Func<T> compiled = (Func<T>)lambdaExpression.Compile();
return compiled;
Func<T> compiled = (Func<T>)lambdaExpression.Compile();
return compiled;
}
catch
{
// an error can be thrown if constructor is not valid on Win8
// will have INVOCATION_FLAGS_NON_W8P_FX_API invocation flag
return () => (T)Activator.CreateInstance(type);
}
}
public override Func<T, object> CreateGet<T>(PropertyInfo propertyInfo)