script async test

This commit is contained in:
辉鸭蛋
2024-07-21 12:42:39 +08:00
parent c3922107b5
commit 4243972eeb
13 changed files with 104 additions and 166 deletions

View File

@@ -0,0 +1,25 @@
using System.Threading.Tasks;
using Microsoft.ClearScript;
using BetterGenshinImpact.Core.Script.Dependence;
namespace BetterGenshinImpact.Core.Script;
public class EngineExtend
{
public static void InitHost(IScriptEngine engine)
{
// engine.AddHostObject("xHost", new ExtendedHostFunctions()); // 有越权的安全风险
// 添加我的自定义实例化对象
engine.AddHostObject("genshin", new Dependence.Genshin());
engine.AddHostObject("log", new Log());
// 添加方法
#pragma warning disable CS8974 // Converting method group to non-delegate type
engine.AddHostObject("sleep", GlobalMethod.Sleep);
#pragma warning restore CS8974 // Converting method group to non-delegate type
// 添加C#的类型
engine.AddHostType(typeof(Task));
}
}