本文整理汇总了C#中JintEngine.SetParameter方法的典型用法代码示例。如果您正苦于以下问题:C# JintEngine.SetParameter方法的具体用法?C# JintEngine.SetParameter怎么用?C# JintEngine.SetParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JintEngine
的用法示例。
在下文中一共展示了JintEngine.SetParameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
// string script = new StreamReader(assembly.GetManifestResourceStream("Jint.Tests.Parse.coffeescript-debug.js")).ReadToEnd();
JintEngine jint = new JintEngine()
// .SetDebugMode(true)
.DisableSecurity()
.SetFunction("print", new Action<object>(Console.WriteLine));
sw.Reset();
jint.SetMaxRecursions(50);
jint.SetMaxSteps(10*1000);
jint.SetParameter("val", double.NaN);
sw.Start();
try
{
Console.WriteLine(
jint.Run(File.ReadAllText(@"C:\Work\ravendb-2.5\SharedLibs\Sources\jint-22024d8a6e7a\Jint.Play\test.js")));
}
catch (Exception e)
{
Console.WriteLine(e);
}
finally
{
Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
}
}
示例2: ShouldNotReproduceBug85418
public void ShouldNotReproduceBug85418() {
var engine = new JintEngine();
engine.SetParameter("a", 4);
Assert.AreEqual(4, engine.Run("a"));
Assert.AreEqual(4d, engine.Run("4"));
Assert.AreEqual(true, engine.Run("a == 4"));
Assert.AreEqual(true, engine.Run("4 == 4"));
Assert.AreEqual(true, engine.Run("a == a"));
}
示例3: ShouldNotThrowOverflowExpcetion
public void ShouldNotThrowOverflowExpcetion() {
var jint = new JintEngine();
jint.SetParameter("box", new Box());
jint.Run("box.Write(new Date);");
}