Hello!
You can do something like this:
This should return all global properties that aren't standard JavaScript built-ins.
Not knowing what kind of objects might be in your script environment, it's difficult to say. Would you expect many .NET objects, and if so, what types? What about script functions? Some script functions may be serializable, but some may not (e.g., those created via
Good luck, and please let us know if you encounter any specific issues!
1) How do I get access to all root objects from inside the CLR?
You can do something like this:
foreach (var name in engine.Script.GetDynamicMemberNames()) { var obj = engine.Script[name]; // do something with obj }
2) Any advice on things to look out for?
Not knowing what kind of objects might be in your script environment, it's difficult to say. Would you expect many .NET objects, and if so, what types? What about script functions? Some script functions may be serializable, but some may not (e.g., those created via
bind()
). One thing you should definitely avoid is using JSON.stringify()
to serialize .NET objects.Good luck, and please let us know if you encounter any specific issues!