-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathExample1.cs
57 lines (52 loc) · 1.15 KB
/
Example1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Puerts;
using XLua;
/// <summary>
/// 静态方法调用
/// 逻辑: 无
/// 参数: 无
/// 返回值: 无
/// </summary>
[Test]
[TestGroup("Static vs Instance", 1, Desc = "静态函数 vs 实例函数")]
[TestGroup("ParameterCompare", 1, Desc = "无参数 vs 有参数")]
public class Example1 : IExecute
{
public bool Static => true;
public string Method => "void Payload();";
public CallTarget Target => CallTarget.ScriptCallCSharp;
public object RunCS(int count)
{
for (var i = 0; i < count; i++)
{
Example1.Payload();
}
return null;
}
public object RunJS(JsEnv env, int count)
{
env.Eval(string.Format(
@"(function() {{
var Example = require('csharp').Example1;
for(let i = 0; i < {0}; i++){{
Example.Payload();
}}
}})()", count));
return null;
}
public object RunLua(LuaEnv env, int count)
{
env.DoString(string.Format(
@"
(function()
local Example = CS.Example1;
for i = 1,{0} do
Example.Payload();
end
end)()
", count));
return null;
}
public static void Payload()
{
}
}