本文整理汇总了C#中ScriptEngine.AddClass方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptEngine.AddClass方法的具体用法?C# ScriptEngine.AddClass怎么用?C# ScriptEngine.AddClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptEngine
的用法示例。
在下文中一共展示了ScriptEngine.AddClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PropertyInteger
public void PropertyInteger()
{
var script = new ScriptEngine();
var test = script.AddClass("Test");
test.AddProperty("test", 10);
Assert.AreEqual(10, script.Evaluate<int>("Test.test"));
}
示例2: PropertyString
public void PropertyString()
{
var script = new ScriptEngine();
var test = script.AddClass("Test");
test.AddProperty("test", "Hello World!");
Assert.AreEqual("Hello World!", script.Evaluate<string>("Test.test"));
}
示例3: PropertyDouble
public void PropertyDouble()
{
var script = new ScriptEngine();
var test = script.AddClass("Test");
test.AddProperty("test", 10.0);
Assert.AreEqual(10.0, script.Evaluate<double>("Test.test"));
}
示例4: PropertyBoolTrue
public void PropertyBoolTrue()
{
var script = new ScriptEngine();
var test = script.AddClass("Test");
test.AddProperty("test", true);
Assert.AreEqual(true, script.Evaluate<bool>("Test.test"));
}
示例5: FunctionString
public void FunctionString()
{
var script = new ScriptEngine();
var debugClass = script.AddClass("debug");
debugClass.AddAction<string>("log", message =>
{
Assert.AreEqual("Hello World!", message);
});
script.Execute("debug.log('Hello World!')");
}
示例6: DebugLogInteger
public void DebugLogInteger()
{
var script = new ScriptEngine();
var debugClass = script.AddClass("debug");
debugClass.AddAction<int>("log", message =>
{
Assert.AreEqual(42, message);
});
script.Execute("debug.log(42)");
}
示例7: DebugLogBoolean
public void DebugLogBoolean()
{
var script = new ScriptEngine();
var debugClass = script.AddClass("debug");
debugClass.AddAction<bool>("log", message =>
{
Assert.AreEqual(true, message);
});
script.Execute("debug.log(true)");
}
示例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!'])");
}