I am trying to pass a JavaScript array to a host function, but can find no documentation on how to do this using ClearScript. I would have expected it to be this simple, but it's not.
public class myHostType
{
public static void print(string format, object[] args)
{
//TODO: implement print
}
}
...
engine.addHostType("console", typeof(myHostType));
engine.Execute("console.print('Hello', ['World', 42])");
With this code I get Error: The best overloaded method match for V8SScript1.myHostType.print(string, object[])' has some invalid arguments.'
This is the closest thing I can find to a solution. Is there not a better way of doing this?
public class myHostType
{
public static void print(string format, dynamic args)
{
var realArgs = new Object[args.length];
for (int i = 0; i < realArgs.Length; ++i)
{
realArgs[i] = args[i];
}
//TODO: implement print
}
}