|
@@ -2,6 +2,7 @@
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Linq.Expressions;
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
using Jint.Native;
|
|
using Jint.Native;
|
|
using Jint.Native.Array;
|
|
using Jint.Native.Array;
|
|
@@ -36,28 +37,28 @@ namespace Jint.Runtime.Interop
|
|
var parameters = new object[arguments.Length];
|
|
var parameters = new object[arguments.Length];
|
|
var argumentsMatch = true;
|
|
var argumentsMatch = true;
|
|
|
|
|
|
- for (var i = 0; i < arguments.Length; i++)
|
|
|
|
- {
|
|
|
|
- var parameterType = method.GetParameters()[i].ParameterType;
|
|
|
|
|
|
+ for (var i = 0; i < arguments.Length; i++)
|
|
|
|
+ {
|
|
|
|
+ var parameterType = method.GetParameters()[i].ParameterType;
|
|
|
|
|
|
- if (parameterType == typeof(JsValue))
|
|
|
|
- {
|
|
|
|
- parameters[i] = arguments[i];
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ if (parameterType == typeof(JsValue))
|
|
|
|
+ {
|
|
|
|
+ parameters[i] = arguments[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
if (!converter.TryConvert(arguments[i].ToObject(), parameterType, CultureInfo.InvariantCulture, out parameters[i]))
|
|
if (!converter.TryConvert(arguments[i].ToObject(), parameterType, CultureInfo.InvariantCulture, out parameters[i]))
|
|
{
|
|
{
|
|
argumentsMatch = false;
|
|
argumentsMatch = false;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- if (typeof(System.Linq.Expressions.LambdaExpression).IsAssignableFrom(parameters[i].GetType()))
|
|
|
|
- {
|
|
|
|
- parameters[i] = (parameters[i] as System.Linq.Expressions.LambdaExpression).Compile();
|
|
|
|
- }
|
|
|
|
|
|
+ if (parameters[i] is LambdaExpression)
|
|
|
|
+ {
|
|
|
|
+ parameters[i] = (parameters[i] as LambdaExpression).Compile();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
if (!argumentsMatch)
|
|
if (!argumentsMatch)
|
|
{
|
|
{
|