Greetings!
Not automatically. ClearScript provides C#-like type inference, where method overloads are selected according to the argument types. Script functions are not strongly typed, and that presents a problem. To create a callback into script code, you must therefore specify the callback type:
Good luck!
I guess that the javascript function is not transform into C# Action?
Not automatically. ClearScript provides C#-like type inference, where method overloads are selected according to the argument types. Script functions are not strongly typed, and that presents a problem. To create a callback into script code, you must therefore specify the callback type:
engine.AddHostObject("Datas", new List<string> { "foo", "bar", "baz" }); engine.AddHostType("Callback", typeof(Action<string>)); engine.AddHostType("Console", typeof(Console)); engine.Execute(@" Datas.ForEach(new Callback(function(d) { Console.WriteLine(d); })) ");