Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Edited Issue: Influence the available commands while execution [21]

0
0
Hi ClearScript,

when I execute JavaScript code I have to add objects, types etc. before I call execute. The JavaScript code itself has not influence which objects or types are available.

But what I want is that the JavaScript Code itself has got an option to define what objects / types etc. it needs an the runtime has the option to add it, like following pseudocode

1st. the bootstrap

```
using (var engine = new V8ScriptEngine())
{
engine.AddHostObject("using", MyApp.PackageManager);
... ' something what is additionally need
engine.Execute(myscript);
}
```

2nd, the JavaScript

```
using.AddType("System.Environment");

var username = Enviroment.UserName;
```

3rd, the "MyApp.PackageManager"

```
static void AddType(string name)
{
_ V8ScriptEngine.Current.AddHostType(name);_
}
```

I know, there is no option like V8ScriptEngine.Current at the moment. But is there another way to do this?

Best regards,
Torsten

Viewing all articles
Browse latest Browse all 2297