Various changes and tweaks to run better
This commit is contained in:
@@ -44,16 +44,6 @@ namespace Upsilon.BaseTypes.ScriptFunction
|
||||
|
||||
public override ScriptType Run(Diagnostics diagnostics, ScriptType[] variables, Script script, EvaluationScope scope)
|
||||
{
|
||||
var types = _directTypeManipulation
|
||||
? variables.Select(x => x.GetType()).ToArray()
|
||||
: variables.Select(x => x.GetCSharpType()).ToArray();
|
||||
var method = _method.GetMethod(types);
|
||||
if (method == null)
|
||||
{
|
||||
throw new Exception(
|
||||
$"No valid function found on type '{_object.GetType()}' with name '{_method.Name}' " +
|
||||
$"and parameter types: {string.Join(", ", types.Select(x => $"'{x.Name}'"))}");
|
||||
}
|
||||
var objects = new List<object>();
|
||||
if (_passScriptReference)
|
||||
objects.Add(script);
|
||||
@@ -62,19 +52,11 @@ namespace Upsilon.BaseTypes.ScriptFunction
|
||||
objects.AddRange(_directTypeManipulation
|
||||
? variables.Select(x => (object) x).ToList()
|
||||
: variables.Select(x => x.ToCSharpObject()).ToList());
|
||||
var pars = method.GetParameters();
|
||||
if (pars.Length != objects.Count)
|
||||
{
|
||||
for (var i = objects.Count; i < pars.Length; i++)
|
||||
{
|
||||
objects.Add(null);
|
||||
}
|
||||
}
|
||||
|
||||
object result;
|
||||
try
|
||||
{
|
||||
result = method.Invoke(_object, objects.ToArray());
|
||||
result = _object.GetType().InvokeMember(_method.Name, BindingFlags.InvokeMethod, System.Type.DefaultBinder,
|
||||
_object, objects.ToArray());
|
||||
}
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user