using System; using System.Collections.Generic; using System.IO; using System.Net; using ILRuntime.Runtime.Intepreter; using ProtoBuf; using UnityEngine; namespace ET { public static class ILHelper { public static List list = new List(); public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(Dictionary)); list.Add(typeof(List)); list.Add(typeof(List)); list.Add(typeof(List)); list.Add(typeof(List)); list.Add(typeof(List)); list.Add(typeof(ETTask)); list.Add(typeof(ETTask)); list.Add(typeof(ETTask)); list.Add(typeof(ETTask)); list.Add(typeof(ETTask)); list.Add(typeof(ETTask)); list.Add(typeof(ListComponent)); list.Add(typeof(ListComponent)); list.Add(typeof(ListComponent)); // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate>(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterMethodDelegate(); appdomain.DelegateManager.RegisterFunctionDelegate(); appdomain.DelegateManager.RegisterFunctionDelegate(); appdomain.DelegateManager.RegisterFunctionDelegate(); appdomain.DelegateManager.RegisterFunctionDelegate, System.String>(); appdomain.DelegateManager.RegisterFunctionDelegate, System.Boolean>(); appdomain.DelegateManager.RegisterFunctionDelegate, System.Int32>(); appdomain.DelegateManager.RegisterFunctionDelegate, int>(); appdomain.DelegateManager.RegisterFunctionDelegate, bool>(); appdomain.DelegateManager.RegisterFunctionDelegate();//Linq appdomain.DelegateManager.RegisterFunctionDelegate();//Linq appdomain.DelegateManager.RegisterFunctionDelegate>, bool>(); appdomain.DelegateManager.RegisterFunctionDelegate, KeyValuePair, int>(); appdomain.DelegateManager.RegisterDelegateConvertor((act) => { return new UnityEngine.Events.UnityAction(() => { ((Action)act)(); }); }); appdomain.DelegateManager.RegisterDelegateConvertor>>((act) => { return new Comparison>((x, y) => { return ((Func, KeyValuePair, int>)act)(x, y); }); }); // 注册适配器 RegisterAdaptor(appdomain); //注册Json的CLR LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); //注册ProtoBuf的CLR PType.RegisterILRuntimeCLRRedirection(appdomain); //////////////////////////////////// // CLR绑定的注册,一定要记得将CLR绑定的注册写在CLR重定向的注册后面,因为同一个方法只能被重定向一次,只有先注册的那个才能生效 //////////////////////////////////// Type t = Type.GetType("ILRuntime.Runtime.Generated.CLRBindings"); if (t != null) { t.GetMethod("Initialize")?.Invoke(null, new object[] { appdomain }); } //ILRuntime.Runtime.Generated.CLRBindings.Initialize(appdomain); } public static void RegisterAdaptor(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { //注册自己写的适配器 appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor()); } } }