github:sebastienros/jint: Javascript Interpreter for .NET
github:DHclly/IceDog.Jint.Test: test jint
nuget:NuGet 库 |金特 3.1.1 --- NuGet Gallery | Jint 3.1.1
塞巴斯蒂安·罗斯在金特上说: .NET 的 Javascript 解释器 | Microsoft Learn
Code Conversations | Microsoft Learn
一个简单的 js shell 实现
static void Main(string[] args)
{
var engine = new Engine();
while (true)
{
try
{
Console.Write("[Jint Shell(q! to exit)]>");
var input = Console.ReadLine();
if (input == "q!")
{
Environment.Exit(0);
}
var result = engine.Evaluate(input);
var output = string.Empty;
if (result.IsUndefined())
{
output = input;
}
else
{
output = result.ToString();
}
Console.WriteLine(output);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
发表评论