Closed Tor012 closed 1 year ago
Hello @Tor012,
You appear to be looking for "global members" functionality, where the members of an object are exposed as items at the global scope. ClearScript supports that feature via HostItemFlags
:
var vCar = new CarDef { name = "myCar", color = "yellow" };
engine.AddHostObject("car", HostItemFlags.GlobalMembers, vCar);
Console.WriteLine(engine.Evaluate("car.color")); // OK
Console.WriteLine(engine.Evaluate("color")); // OK
Please let us know if that doesn't work for you. Thanks!
Thank you, that works perfect.
Please reopen this issue if you have additional questions about this topic. Thank you!
Is it possible to evaluate a property via the VBScript engine without having to specify its object explicitly. This was possible in the "old" MS ScriptControl.
Perhaps the property could be searched in all host objects or a main object could be defined.
Sample code follows