Greetings!
ClearScript was designed to provide direct access to script objects, without data conversion. For example, you could write your C# class as follows:
and then use it like this:
Keep in mind, however, that host-to-script and script-to-host calls are relatively expensive. Data conversion can actually yield better performance in many cases. With JSON, for example, you can package your data and move it across the boundary in one step, but of course you have to weigh that against the costs of JSON serialization and parsing.
Good luck, and thanks for your question!
ClearScript was designed to provide direct access to script objects, without data conversion. For example, you could write your C# class as follows:
publicclass ConsolePlotUtility { publicvoid plot(dynamic data) { for (var i = 0; i < data.length; i++) Console.WriteLine("({0},{1})", data[i][0], data[i][1]); } }
engine.AddHostObject("plotUtility", new ConsolePlotUtility()); engine.Evaluate("plotUtility.plot([[1,2], [3,4], [5,8]])");
Good luck, and thanks for your question!