ILRuntime中使用委托
假如你是在热更新的dll项目内部使用委托,可以直接使用
如果你的委托事件需要在主工程与热更新的dll项目交叉使用,这时候就需要在主工程里注册某个指定类型的委托适配器或者转换器,ILRuntime会抛出相应的异常 ,同时会提示你需要添加的代码,你只需要拷贝复制到对应的注册函数中
例如:
appDomain.DelegateManager.RegisterFunctionDelegate<int, float, bool>();
appDomain.DelegateManager.RegisterDelegateConvertor<SomeFunction>((action) =>
{
return new SomeFunction((a, b) =>
{
return ((Func<int, float, bool>)action)(a, b);
});
});
建议使用Action以及Func