-
-
Save jochemstoel/ead8d90613c7d51aeaeddce5902e18ca to your computer and use it in GitHub Desktop.
Example 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.ClearScript.V8; | |
using Microsoft.ClearScript; | |
namespace v8repl | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var repl = new REPL(); | |
var v8 = repl.GetInstance(); // shortcut | |
/* assign the whole .NET core library to mscorlib */ | |
v8.AddHostObject("mscorlib", new HostTypeCollection("mscorlib")); | |
/* reference full namespace, for example: | |
* mscorlib.System.Console.WriteLine() | |
* mscorlib.System.IO.File.WriteAllText() | |
*/ | |
/* expose the V8ScriptEngine type to the V8 context */ | |
v8.AddHostType("V8ScriptEngine", typeof(V8ScriptEngine)); | |
/* we can now do: | |
* var context1 = new V8ScriptEngine() | |
*/ | |
repl.LoadFile("init.js"); /* evaluate our file init.js */ | |
repl.Start(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment