【问题标题】:Embeddable scripting language for .NET 2.0?.NET 2.0 的可嵌入脚本语言?
【发布时间】:2017-12-29 06:08:14
【问题描述】:

有没有什么好的.NET 可嵌入脚本语言支持.NET 2.0?我发现的每个解决方案都是针对 .NET 3.5 或更高版本的。

【问题讨论】:

标签: c# .net scripting


【解决方案1】:

DynLan - 它还支持 PCL / net4.0 / net3.5 / net2.0 / net.ce / net.core (https://github.com/b-y-t-e/DynLan)。该库解析代码本身并逐行执行。简单表达式示例:

// result = 4
Object result = new Compiler().
  Compile(" 1 + 3 ").
  Eval();

你还可以使用变量/if/elif/else/while语句执行更复杂的代码:

var dict = new Dictionary<string, object>();
dict["maxValue"] = 100;

// result = 100
Object result = new Compiler().
  Compile(@"
    i = 0
    while i < maxValue {
      i = i + 1
    }
    return i
").Eval(dict);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-20
    • 2015-02-14
    • 2010-10-02
    • 2011-01-09
    • 2011-04-20
    • 1970-01-01
    • 2013-02-21
    • 1970-01-01
    相关资源
    最近更新 更多