Hi Chris,
First, consider upgrading to the latest version of ClearScript (currently 5.4.1). We recommend that you build it from the source code as outlined in the ReadMe.
Second, you've determined correctly that ClearScript prefers to make host objects scriptable rather than convert them to script objects. However, it also aims to make it easy to manipulate script objects from the host. Here's a sample that defines an extension method for converting host arrays to script arrays:
Note that
Good luck!
First, consider upgrading to the latest version of ClearScript (currently 5.4.1). We recommend that you build it from the source code as outlined in the ReadMe.
Second, you've determined correctly that ClearScript prefers to make host objects scriptable rather than convert them to script objects. However, it also aims to make it easy to manipulate script objects from the host. Here's a sample that defines an extension method for converting host arrays to script arrays:
publicstaticclass ScriptHelpers { publicstaticobject ToScriptArray<T>(this T[] array) { dynamic scriptArray = ScriptEngine.Current.Evaluate("[]"); foreach (var element in array) { scriptArray.push(element); } return scriptArray; } }
ScriptEngine.Current
is new in ClearScript 5.4.1. With an older version you'd have to pass the engine instance into the conversion method (or use some other technique).Good luck!