1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using Jint.Native;
- using Jint.Runtime;
- namespace Jint.Repl
- {
- class Program
- {
- static void Main(string[] args)
- {
- var engine = new Engine()
- .SetValue("log", new Action<object>(Console.WriteLine))
- ;
- while (true)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Write(" > ");
- var input = Console.ReadLine();
- if (input == "exit")
- {
- return;
- }
- try
- {
- var result = engine.GetValue(engine.Execute(input));
- var str = TypeConverter.ToString(engine.Json.Stringify(engine.Json, Arguments.From(result, Undefined.Instance, " ")));
- Console.ForegroundColor = ConsoleColor.Magenta;
- Console.WriteLine("=> {0}", str);
- }
- catch (JavaScriptException je)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine(je.ToString());
- }
-
- }
- }
- }
- }
|