本文整理匯總了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);
}