当前位置: 首页>>代码示例>>C#>>正文


C# ScriptEngine.Exception方法代码示例

本文整理汇总了C#中ScriptEngine.Exception方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptEngine.Exception方法的具体用法?C# ScriptEngine.Exception怎么用?C# ScriptEngine.Exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScriptEngine的用法示例。


在下文中一共展示了ScriptEngine.Exception方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ArithmeticIntegerAddString

 public void ArithmeticIntegerAddString()
 {
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.Fail(e.Message);
     });
     Assert.AreEqual("40text", script.Evaluate<string>("40 + 'text'"));
 }
开发者ID:Templarian,项目名称:Script,代码行数:9,代码来源:ArithmeticInteger.cs

示例2: ArithmeticIntegerDivideInterger

 public void ArithmeticIntegerDivideInterger()
 {
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.Fail(e.Message);
     });
     Assert.AreEqual(20.0, script.Evaluate<double>("40 / 2"));
 }
开发者ID:Templarian,项目名称:Script,代码行数:9,代码来源:ArithmeticInteger.cs

示例3: ArithmeticIntegerAddInteger

 public void ArithmeticIntegerAddInteger()
 {
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.Fail(e.Message);
     });
     Assert.AreEqual(42, script.Evaluate<int>("40 + 2"));
 }
开发者ID:Templarian,项目名称:Script,代码行数:9,代码来源:ArithmeticInteger.cs

示例4: ArithmeticIntegerAddListString

 public void ArithmeticIntegerAddListString()
 {
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.Fail(e.Message);
     });
     Assert.AreEqual("40hello,world,!", script.Evaluate<string>("40 + ['hello', 'world', '!']"));
 }
开发者ID:Templarian,项目名称:Script,代码行数:9,代码来源:ArithmeticInteger.cs

示例5: VariableStringToInt

 public void VariableStringToInt()
 {
     var script = new ScriptEngine();
     var code = new StringBuilder();
     script.Exception(error =>
     {
         Assert.AreEqual("String 'foo' set to Integer on Line 1 Col 13", error.Message);
     });
     code.AppendLine("string foo = 4");
     code.AppendLine("foo");
     script.Execute(code.ToString());
 }
开发者ID:Templarian,项目名称:Script,代码行数:12,代码来源:Variable.cs

示例6: FunctionInvalidArguments

 public void FunctionInvalidArguments()
 {
     var script = new ScriptEngine();
     script.AddAction<string>("log", message =>
     {
         Assert.Fail();
     });
     script.Exception(e =>
     {
         Assert.AreEqual("Unexpected string on Line 1 Col 14", e.Message);
     });
     script.Execute("log('Missing' 'Comma!')");
 }
开发者ID:Templarian,项目名称:Script,代码行数:13,代码来源:Function.cs

示例7: DebugLogSetList

 public void DebugLogSetList()
 {
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.Fail(e.Message);
     });
     var code = new StringBuilder();
     code.AppendLine("string[] foo = ['Hello', 'World!']");
     code.AppendLine("foo");
     var value = script.Evaluate<List<string>>(code.ToString());
     Assert.AreEqual(value[0], "Hello");
 }
开发者ID:Templarian,项目名称:Script,代码行数:13,代码来源:Debug.cs

示例8: DebugLogArray

 public void DebugLogArray()
 {
     var script = new ScriptEngine();
     var debugClass = script.AddClass("debug");
     debugClass.AddAction<List<string>>("log", message =>
     {
         Assert.AreEqual("Hello World!", message[0]);
     });
     script.Exception(e =>
     {
         Assert.Fail(e.Message);
     });
     script.Execute("debug.log(['Hello World!'])");
 }
开发者ID:Templarian,项目名称:Script,代码行数:14,代码来源:Debug.cs

示例9: ConditionBoolFalseOrFalse

 public void ConditionBoolFalseOrFalse()
 {
     var script = new ScriptEngine();
     script.Exception(ExceptionHandler);
     script.AddCondition<string>("foo", message =>
     {
         return "bar" == message;
     });
     script.AddAction<string>("log", message =>
     {
         Assert.Fail("This should never be called.");
     });
     var code = new StringBuilder();
     code.AppendLine("if (foo('fail1') and foo('fail2'))"); // Basic if statment
     code.AppendLine("    log('Hello World!')"); // Should run log, pass { indent: 1 }
     script.Execute(code.ToString());
 }
开发者ID:Templarian,项目名称:Script,代码行数:17,代码来源:Condition.cs

示例10: button_Click

 private void button_Click(object sender, RoutedEventArgs e)
 {
     var engine = new ScriptEngine();
     engine.Exception(err =>
     {
         error.Text = err.Message;
     });
     engine.AddAction<string>("log", ActionMessage);
     Stopwatch stopWatch = new Stopwatch();
     stopWatch.Start();
     output.Text = engine.Evaluate<string>(code.Text);
     stopWatch.Stop();
     // Get the elapsed time as a TimeSpan value.
     TimeSpan ts = stopWatch.Elapsed;
     time.Text = String.Format("({0:00}.{1:00})",
         ts.Seconds,
         ts.Milliseconds / 10);
 }
开发者ID:Templarian,项目名称:Script,代码行数:18,代码来源:MainPage.xaml.cs

示例11: ArithmeticIntegerMinusDouble

 public void ArithmeticIntegerMinusDouble()
 {
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.Fail(e.Message);
     });
     Assert.AreEqual(38.0, script.Evaluate<double>("40 - 2.0"));
 }
开发者ID:Templarian,项目名称:Script,代码行数:9,代码来源:ArithmeticInteger.cs

示例12: ArithmeticIntegerDivideString

 public void ArithmeticIntegerDivideString()
 {
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.AreEqual("Unable to cast value 'text' from 'String' to 'Double' on Line 1 Col 5", e.Message);
     });
     script.Execute("40 / 'text'");
 }
开发者ID:Templarian,项目名称:Script,代码行数:9,代码来源:ArithmeticInteger.cs

示例13: ListStringNestedAndRead

 public void ListStringNestedAndRead()
 {
     // Nested arrays are not supported.
     var script = new ScriptEngine();
     script.Exception(e =>
     {
         Assert.AreEqual("Invalid data type 'ListString' in 'String' list near Line 1 Col 36", e.Message);
     });
     var code = new StringBuilder();
     code.AppendLine("string[] foo = [['Hello', 'Again'], 'World!']");
     code.AppendLine("foo[0][0]");
     var value = script.Evaluate<string>(code.ToString());
     Assert.AreNotEqual(value, "Hello");
 }
开发者ID:Templarian,项目名称:Script,代码行数:14,代码来源:Debug.cs


注:本文中的ScriptEngine.Exception方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。