本文整理汇总了C#中System.Script.Call方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Call方法的具体用法?C# Script.Call怎么用?C# Script.Call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Script
的用法示例。
在下文中一共展示了Script.Call方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintTest2
public void PrintTest2()
{
string script = @"
t = {};
m = {};
function m.__tostring()
return 'ciao';
end
setmetatable(t, m);
print(t, 1);
";
string printed = null;
Script S = new Script();
DynValue main = S.LoadString(script);
S.Options.DebugPrint = s =>
{
printed = s;
};
S.Call(main);
Assert.AreEqual("ciao\t1", printed);
}
示例2: MetatableCall2
public void MetatableCall2()
{
string script = @"
t = { }
meta = { }
x = 0;
function meta.__call(f, y)
x = 156 * y;
return x;
end
setmetatable(t, meta);
return t;
";
Script S = new Script();
DynValue tbl = S.DoString(script);
DynValue res = S.Call(tbl, 3);
Assert.AreEqual(DataType.Number, res.Type);
Assert.AreEqual(468, res.Number);
}
示例3: PrintTest1
public void PrintTest1()
{
string script = @"
print('ciao', 1);
";
string printed = null;
Script S = new Script();
DynValue main = S.LoadString(script);
S.Options.DebugPrint = s =>
{
printed = s;
};
S.Call(main);
Assert.AreEqual("ciao\t1", printed);
}