microsoft / ClearScript

A library for adding scripting to .NET applications. Supports V8 (Windows, Linux, macOS) and JScript/VBScript (Windows).
https://microsoft.github.io/ClearScript/
MIT License
1.79k stars 148 forks source link

Question: ScriptEngine.HostData #569

Closed dementcore closed 8 months ago

dementcore commented 8 months ago

Hi!

I have a doubt about ScriptEngine.HostData property. What is the intended form of using it??

Thanks!!!

ClearScriptLib commented 8 months ago

Hi @dementcore,

HostData allows the host application to associate arbitrary data with a script engine. The script engine does nothing with the property value except hold onto it on the application's behalf – something that could be useful in applications that manage multiple script engines.

Allowing the host to associate arbitrary data with library objects is a common API pattern.

Good luck!

dementcore commented 8 months ago

Thanks for your answer!

There is a way to obtain the executing scriptengine when a host exposed method is invoked from script?

ClearScriptLib commented 8 months ago

There is a way to obtain the executing scriptengine when a host exposed method is invoked from script?

Yes, you can use ScriptEngine.Current.

ClearScriptLib commented 8 months ago

Please reopen this issue if you have additional questions related to this topic. Thank you!