public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); //注册绑定的导出类 //CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(ILRegister).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { #if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE) //由于Unity的Profiler接口只允许在主线程使用,为了避免出异常,需要告诉ILRuntime主线程的线程ID才能正确将函数运行耗时报告给Profiler appdomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #endif //这里做一些ILRuntime的注册,这里我们注册值类型Binder,注释和解注下面的代码来对比性能差别 appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appdomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); appdomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); InitDelegates(appdomain); SetupCLRRedirection(appdomain); // 注册适配器(需要在适配器添加 ILAdapterAttribute 标签) Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } CLRBindings.Initialize(appdomain); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <float, float>(); appdomain.DelegateManager.RegisterMethodDelegate <float, float, float>(); appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, byte, ushort, MemoryStream>(); appdomain.DelegateManager.RegisterMethodDelegate <Session>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterMethodDelegate <EventContext>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.EventCallback0>((act) => { return(new FairyGUI.EventCallback0(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.EventCallback1>((act) => { return(new FairyGUI.EventCallback1((context) => { ((Action <FairyGUI.EventContext>)act)(context); })); }); CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
//======================================================================== //注册函数 //======================================================================== public void RegisterCrossBindingAdaptor(CrossBindingAdaptor adaptor) { if (m_appdomain != null) { m_appdomain.RegisterCrossBindingAdaptor(adaptor); } else { Debuger.LogError("ILRuntime的AppDomain未创建!"); } }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <object>(); appdomain.DelegateManager.RegisterMethodDelegate <object[]>(); appdomain.DelegateManager.RegisterMethodDelegate <long>(); appdomain.DelegateManager.RegisterMethodDelegate <ulong>(); appdomain.DelegateManager.RegisterMethodDelegate <int>(); appdomain.DelegateManager.RegisterMethodDelegate <uint>(); appdomain.DelegateManager.RegisterMethodDelegate <short>(); appdomain.DelegateManager.RegisterMethodDelegate <ushort>(); appdomain.DelegateManager.RegisterMethodDelegate <char>(); appdomain.DelegateManager.RegisterMethodDelegate <string>(); appdomain.DelegateManager.RegisterMethodDelegate <object, object>(); appdomain.DelegateManager.RegisterMethodDelegate <int, object>(); appdomain.DelegateManager.RegisterMethodDelegate <long, object>(); appdomain.DelegateManager.RegisterMethodDelegate <string, object>(); appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); ILRegType.RegisterMethodDelegate(appdomain); ILRegType.RegisterFunctionDelegate(appdomain); ILRegType.RegisterDelegateConvertor(appdomain); //CLR绑定 CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(GameEntry).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public static unsafe void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appDomain) { // 注册重定向函数 // 注册委托 appDomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appDomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appDomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appDomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, Packet>(); appDomain.DelegateManager.RegisterMethodDelegate <Session>(); appDomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appDomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Boolean>(); appDomain.DelegateManager.RegisterDelegateConvertor <Predicate <ILTypeInstance> >((act) => { return(new Predicate <ILTypeInstance>((obj) => { return ((Func <ILTypeInstance, System.Boolean>)act)(obj); })); }); CLRBindings.Initialize(appDomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appDomain.RegisterCrossBindingAdaptor(adaptor); } // 初始化ILRuntime的protobuf InitializeILRuntimeProtobuf(appDomain); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, byte, ushort, MemoryStream>(); appdomain.DelegateManager.RegisterMethodDelegate <Session>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); // Task Override appdomain.DelegateManager.RegisterFunctionDelegate <TaskStatus>(); appdomain.DelegateManager.RegisterFunctionDelegate <object, bool>(); // ParentTask Override appdomain.DelegateManager.RegisterFunctionDelegate <TaskStatus, TaskStatus>(); appdomain.DelegateManager.RegisterMethodDelegate <int, TaskStatus>(); appdomain.DelegateManager.RegisterMethodDelegate <TaskStatus>(); CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public void Register(AppDomain appdomain) { //自动注册一波,无需再手动添加了,如果想要性能也可以手动自己加 Assembly assembly = typeof(InitJEngine).Assembly; foreach (Type type in assembly.GetTypes().ToList().FindAll(t => t.IsSubclassOf(typeof(CrossBindingAdaptor)))) { object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } }
public static unsafe void InitILRuntime() { // 注册重定向函数 MethodInfo mi = typeof(Log).GetMethod("Debug", new Type[] { typeof(string) }); Init.Instance.AppDomain.RegisterCLRMethodRedirection(mi, ILRedirection.LogDebug); MethodInfo mi2 = typeof(Log).GetMethod("Info", new Type[] { typeof(string) }); Init.Instance.AppDomain.RegisterCLRMethodRedirection(mi2, ILRedirection.LogInfo); MethodInfo mi3 = typeof(Log).GetMethod("Error", new Type[] { typeof(string) }); Init.Instance.AppDomain.RegisterCLRMethodRedirection(mi3, ILRedirection.LogError); // 注册委托 Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate <List <object> >(); Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate <IResponse>(); Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate <Session, PacketInfo>(); Init.Instance.AppDomain.DelegateManager.RegisterMethodDelegate <Session, object>(); CLRBindings.Initialize(Init.Instance.AppDomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } Init.Instance.AppDomain.RegisterCrossBindingAdaptor(adaptor); } // 初始化ILRuntime的protobuf InitializeILRuntimeProtobuf(); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册不带返回值的委托 RegisterMethodDelegate(appdomain); // 注册带返回值的委托 RegisterFunctionDelegate(appdomain); // 注册复杂委托 RegisterDelegateConvertor(appdomain); // 执行绑定 //CLRBindings.Initialize(appdomain); // 跨域绑定适配器 Assembly assembly = typeof(ILHelper).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } //demo //appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); //appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter()); //appdomain.RegisterCrossBindingAdaptor(new InheritanceAdapter()); //appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); // 注册LitJson //LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public void RegisterILAdapter() { Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } AppDomain.RegisterCrossBindingAdaptor(adaptor); } }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } domain.RegisterCrossBindingAdaptor(adaptor); } }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Type>(); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { ((Action)act)(); })); }); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
private void Awake() { appDomain = new ILRuntime.Runtime.Enviorment.AppDomain(); GameObject code = (GameObject)Resources.Load("Code"); byte[] assBytes = code.Get <TextAsset>("Hotfix.dll").bytes; byte[] mdbBytes = code.Get <TextAsset>("Hotfix.pdb").bytes; using (MemoryStream fs = new MemoryStream(assBytes)) using (MemoryStream p = new MemoryStream(mdbBytes)) { appDomain.LoadAssembly(fs, p, new Mono.Cecil.Pdb.PdbReaderProvider()); } Assembly assembly = Game.EntityEventManager.GetAssembly("Model"); foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appDomain.RegisterCrossBindingAdaptor(adaptor); } this.start = appDomain.LoadedTypes["Hotfix.HotfixEntry"].GetMethod("Start", 0); appDomain.Invoke(this.start, null, param0); }
/// <summary> /// 注册适配器 /// </summary> /// <typeparam name="T"></typeparam> public static void InitAdaptor <T>(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册适配器 Assembly assembly = typeof(T).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public static unsafe void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appDomain) { // 注册重定向函数 // 注册委托 appDomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appDomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appDomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appDomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, PacketInfo>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, uint, object>(); CLRBindings.Initialize(appDomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appDomain.RegisterCrossBindingAdaptor(adaptor); } // 初始化ILRuntime的protobuf InitializeILRuntimeProtobuf(appDomain); }
//初始化 public static void InitILRuntime(AppDomain appDomain) { //注册委托参数 //GF用 appDomain.DelegateManager.RegisterMethodDelegate <float>(); appDomain.DelegateManager.RegisterMethodDelegate <object, GameFramework.Event.GameEventArgs>(); appDomain.DelegateManager.RegisterMethodDelegate <float, float>(); appDomain.DelegateManager.RegisterMethodDelegate <bool>(); appDomain.DelegateManager.RegisterMethodDelegate <object>(); appDomain.DelegateManager.RegisterMethodDelegate <string, string, string, object>(); //加载资源失败的回调 appDomain.DelegateManager.RegisterMethodDelegate <string, object, float, object>(); //加载资源成功的回调 //ET用 appDomain.DelegateManager.RegisterMethodDelegate <List <object> >(); //appDomain.DelegateManager.RegisterMethodDelegate<AChannel, System.Net.Sockets.SocketError>(); appDomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); //appDomain.DelegateManager.RegisterMethodDelegate<IResponse>(); //appDomain.DelegateManager.RegisterMethodDelegate<Session, object>(); //appDomain.DelegateManager.RegisterMethodDelegate<Session, ushort, MemoryStream>(); //appDomain.DelegateManager.RegisterMethodDelegate<Session>(); //appDomain.DelegateManager.RegisterMethodDelegate<ILTypeInstance>(); //PB用 //appDomain.DelegateManager.RegisterFunctionDelegate<IMessageAdaptor.Adaptor>(); //appDomain.DelegateManager.RegisterMethodDelegate<IMessageAdaptor.Adaptor>(); //注册委托转换器 appDomain.DelegateManager.RegisterDelegateConvertor <UnityAction>((action) => { return(new UnityAction(() => { ((Action)action).Invoke(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityAction <float> >((action) => { return(new UnityAction <float>((a) => { ((Action <float>)action).Invoke(a); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityAction <bool> >((action) => { return(new UnityAction <bool>((a) => { ((Action <bool>)action).Invoke(a); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <EventHandler <GameFramework.Event.GameEventArgs> >((action) => { return(new EventHandler <GameFramework.Event.GameEventArgs>((sender, e) => { ((Action <object, GameFramework.Event.GameEventArgs>)action).Invoke(sender, e); })); }); //注册CLR绑定代码 ILRuntime.Runtime.Generated.CLRBindings.Initialize(appDomain); //注册跨域继承适配器 //Type[] types = Utility.Assembly.GetTypes(); //这里是工程中所有的类型,其实没必要 Type[] types = typeof(HotfixComponent).Assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { Type type = types[i]; object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appDomain.RegisterCrossBindingAdaptor(adaptor); } //注册LitJson LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); }
public static unsafe void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appDomain) { appDomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); appDomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); // 注册重定向函数 // 注册委托适配器 appDomain.DelegateManager.RegisterMethodDelegate <ETVoid>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Int32>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Int64>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Single>(); //float appDomain.DelegateManager.RegisterMethodDelegate <System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <System.String, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Boolean, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <int, int, bool>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Single, System.Single>(); appDomain.DelegateManager.RegisterMethodDelegate <List <System.Object> >(); appDomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Byte[], System.Int32, System.Int32>(); appDomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <System.UInt16, Google.Protobuf.IMessage>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, System.Object>(); appDomain.DelegateManager.RegisterMethodDelegate <Session, System.UInt16, MemoryStream>(); appDomain.DelegateManager.RegisterMethodDelegate <Session>(); appDomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Byte[]>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.UInt16, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Exception>(); appDomain.DelegateManager.RegisterMethodDelegate <HYZ.Cfg.ETModel.NoviceguideDefine>(); appDomain.DelegateManager.RegisterMethodDelegate <HYZ.Cfg.ETModel.GuideHandle>(); appDomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Vector2>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Video.VideoPlayer>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.UI.Text>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.Tab>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.Tab, UnityEngine.EventSystems.PointerEventData>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.TabGroup, UnityEngine.EventSystems.PointerEventData>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Collections.IEnumerator>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Collections.IEnumerator, System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Object>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.BaseSystem>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, ETModel.Match.AnimRunMatchState>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, System.String, System.Boolean, System.Int32, System.Double>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, System.String, System.Int32, System.Double>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.Match.HorseRunData, HYZ.Cfg.ETModel.SkillTriggerContent, System.Int32>(); appDomain.DelegateManager.RegisterMethodDelegate <HorseListItem>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int64>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Double>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Single, System.Single>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int64, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Int32, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Int64>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, ILTypeInstance, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Int64>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.ChallengeDefine, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.EquipmentMaterialList, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.MatchPlayer, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.HorseRunData, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, ETModel.Match.Path>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.Path[]>(); appDomain.DelegateManager.RegisterFunctionDelegate <List <ETModel.Match.HorseRunData> >(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Random>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Double, System.Int32, ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Double, System.Double, System.Int32, ETModel.Match.HorseRunData>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.MatchConst>(); appDomain.DelegateManager.RegisterFunctionDelegate <List <System.Int32> >(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.Match>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.tabtoy.DataProxyComponent>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.HorseBuffManager>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32[]>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.HorseRunData, ETModel.Match.HorseRunData, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.IO.FileInfo, System.IO.FileInfo, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int64, System.Int64, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Collections.IEnumerator, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Collections.IEnumerator>(); appDomain.DelegateManager.RegisterFunctionDelegate <HorseListItem, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ETModel.Match.CameraPathState, int, int, Transform>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.HorseLevelUpDefine, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.DualwingiftDefine, System.Boolean>(); // 注册委托转换器 appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.UInt16, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Exception>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Byte[]>(); appDomain.DelegateManager.RegisterFunctionDelegate <HYZ.Cfg.ETModel.DualConfigDefine, System.Boolean>(); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.DualwingiftDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.DualwingiftDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.DualwingiftDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.DualConfigDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.DualConfigDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.DualConfigDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.HorseLevelUpDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.HorseLevelUpDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.HorseLevelUpDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketOpenDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketOpenDelegate((webSocket) => { ((Action <BestHTTP.WebSocket.WebSocket>)act)(webSocket); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <global::HorseListItem> >((act) => { return(new System.Predicate <global::HorseListItem>((obj) => { return ((Func <global::HorseListItem, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketMessageDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketMessageDelegate((webSocket, message) => { ((Action <BestHTTP.WebSocket.WebSocket, string>)act)(webSocket, message); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketBinaryDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketBinaryDelegate((webSocket, data) => { ((Action <BestHTTP.WebSocket.WebSocket, byte[]>)act)(webSocket, data); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketClosedDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketClosedDelegate((webSocket, code, message) => { ((Action <BestHTTP.WebSocket.WebSocket, UInt16, string>)act)(webSocket, code, message); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketErrorDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketErrorDelegate((webSocket, ex) => { ((Action <BestHTTP.WebSocket.WebSocket, System.Exception>)act)(webSocket, ex); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketErrorDescriptionDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketErrorDescriptionDelegate((webSocket, reason) => { ((Action <BestHTTP.WebSocket.WebSocket, string>)act)(webSocket, reason); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ETModel.Match.MatchPlayer> >((act) => { return(new System.Predicate <ETModel.Match.MatchPlayer>((obj) => { return ((Func <ETModel.Match.MatchPlayer, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ETModel.Match.HorseRunData> >((act) => { return(new System.Predicate <ETModel.Match.HorseRunData>((obj) => { return ((Func <ETModel.Match.HorseRunData, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> >((act) => { return(new UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData>((arg0) => { ((Action <UnityEngine.EventSystems.BaseEventData>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int32> >((act) => { return(new System.Predicate <System.Int32>((obj) => { return ((Func <System.Int32, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.OnRequestFinishedDelegate>((act) => { return(new BestHTTP.OnRequestFinishedDelegate((originalRequest, response) => { ((Action <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>)act)(originalRequest, response); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { //((Action<>)act)(); ((System.Action)act)(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <DG.Tweening.TweenCallback>((act) => { return(new DG.Tweening.TweenCallback(() => { ((System.Action)act)(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <Quick.UI.Tab.PointerTabFunc>((act) => { return(new Quick.UI.Tab.PointerTabFunc((target, eventData) => { ((Action <Quick.UI.Tab, UnityEngine.EventSystems.PointerEventData>)act)(target, eventData); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.String> >((act) => { return(new UnityEngine.Events.UnityAction <System.String>((arg0) => { ((Action <System.String>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) => { return(new System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance>((obj) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int64> >((act) => { return(new System.Predicate <System.Int64>((obj) => { return ((Func <System.Int64, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Video.VideoPlayer.EventHandler>((act) => { return(new UnityEngine.Video.VideoPlayer.EventHandler((source) => { ((Action <UnityEngine.Video.VideoPlayer>)act)(source); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.Vector2> >((act) => { return(new UnityEngine.Events.UnityAction <UnityEngine.Vector2>((arg0) => { ((Action <UnityEngine.Vector2>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) => { return(new System.Comparison <ILRuntime.Runtime.Intepreter.ILTypeInstance>((x, y) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.IO.FileInfo> >((act) => { return(new System.Comparison <System.IO.FileInfo>((x, y) => { return ((Func <System.IO.FileInfo, System.IO.FileInfo, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.Int64> >((act) => { return(new System.Comparison <System.Int64>((x, y) => { return ((Func <System.Int64, System.Int64, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Boolean> >((act) => { return(new UnityEngine.Events.UnityAction <System.Boolean>((arg0) => { ((Action <System.Boolean>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int64> >((act) => { return(new System.Predicate <System.Int64>((obj) => { return ((Func <System.Int64, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.Int32> >((act) => { return(new System.Comparison <System.Int32>((x, y) => { return ((Func <System.Int32, System.Int32, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <ETModel.Match.HorseRunData> >((act) => { return(new System.Comparison <ETModel.Match.HorseRunData>((x, y) => { return ((Func <ETModel.Match.HorseRunData, ETModel.Match.HorseRunData, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Int32> >((act) => { return(new UnityEngine.Events.UnityAction <System.Int32>((arg0) => { ((Action <System.Int32>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Single> >((act) => { return(new UnityEngine.Events.UnityAction <System.Single>((arg0) => { ((Action <System.Single>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.ChallengeDefine> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.ChallengeDefine>((obj) => { return ((Func <HYZ.Cfg.ETModel.ChallengeDefine, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <HYZ.Cfg.ETModel.EquipmentMaterialList> >((act) => { return(new System.Predicate <HYZ.Cfg.ETModel.EquipmentMaterialList>((obj) => { return ((Func <HYZ.Cfg.ETModel.EquipmentMaterialList, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Converter <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64> >((act) => { return(new System.Converter <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64>((input) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64>)act)(input); })); }); CLRBindings.Initialize(appDomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appDomain.RegisterCrossBindingAdaptor(adaptor); } // 初始化ILRuntime的protobuf InitializeILRuntimeProtobuf(appDomain); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); //ILSerial.RegisterILRuntimeCLRRedirection(appDomain); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, ushort, MemoryStream>(); appdomain.DelegateManager.RegisterMethodDelegate <Session>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); appdomain.DelegateManager.RegisterMethodDelegate <float>(); appdomain.DelegateManager.RegisterDelegateConvertor <global::EventTriggerListener.VoidDelegate>((act) => { return(new global::EventTriggerListener.VoidDelegate((go) => { ((Action <UnityEngine.GameObject>)act)(go); })); }); appdomain.DelegateManager.RegisterMethodDelegate <System.Single>(); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Single> >((act) => { return(new UnityEngine.Events.UnityAction <System.Single>((arg0) => { ((Action <System.Single>)act)(arg0); })); }); #region adapter //TODO:Osmin 添加Unity的委托事件 appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((action) => { return(new UnityEngine.Events.UnityAction(() => { ((System.Action)action)(); })); }); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.EventSystems.EventTrigger.Entry>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.EventSystems.BaseEventData>(); appdomain.DelegateManager.RegisterMethodDelegate <System.Object, ILRuntime.Runtime.Intepreter.ILTypeInstance>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> >(); appdomain.DelegateManager.RegisterMethodDelegate <System.Action <UnityEngine.EventSystems.BaseEventData> >(); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> >((action) => { return(new UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData>((a) => { ((System.Action <UnityEngine.EventSystems.BaseEventData>)action)(a); })); }); //appdomain.DelegateManager.RegisterDelegateConvertor<System.Action<UnityEngine.EventSystems.BaseEventData>>((action) => //{ // return new System.Action<UnityEngine.EventSystems.BaseEventData>((a) => // { // ((System.Action<UnityEngine.EventSystems.BaseEventData>)action)(a); // }); //}); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Transform>(); appdomain.DelegateManager.RegisterMethodDelegate <System.String>(); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.String> >((act) => { return(new UnityEngine.Events.UnityAction <System.String>((arg0) => { ((Action <System.String>)act)(arg0); })); }); appdomain.DelegateManager.RegisterMethodDelegate <System.Int32>(); appdomain.DelegateManager.RegisterFunctionDelegate <System.String, System.Int32, System.Char, System.Char>(); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.UI.InputField.OnValidateInput>((act) => { return(new UnityEngine.UI.InputField.OnValidateInput((text, charIndex, addedChar) => { return ((Func <System.String, System.Int32, System.Char, System.Char>)act)(text, charIndex, addedChar); })); }); #endregion CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public static unsafe void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appDomain) { // 注册重定向函数 // 注册委托 appDomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appDomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appDomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.Tab>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.UInt16, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Exception>(); appDomain.DelegateManager.RegisterMethodDelegate <BestHTTP.WebSocket.WebSocket, System.Byte[]>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Boolean>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILTypeInstance, System.Int64>(); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketOpenDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketOpenDelegate((webSocket) => { ((Action <BestHTTP.WebSocket.WebSocket>)act)(webSocket); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketMessageDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketMessageDelegate((webSocket, message) => { ((Action <BestHTTP.WebSocket.WebSocket, string>)act)(webSocket, message); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketBinaryDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketBinaryDelegate((webSocket, data) => { ((Action <BestHTTP.WebSocket.WebSocket, byte[]>)act)(webSocket, data); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketClosedDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketClosedDelegate((webSocket, code, message) => { ((Action <BestHTTP.WebSocket.WebSocket, UInt16, string>)act)(webSocket, code, message); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketErrorDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketErrorDelegate((webSocket, ex) => { ((Action <BestHTTP.WebSocket.WebSocket, System.Exception>)act)(webSocket, ex); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.WebSocket.OnWebSocketErrorDescriptionDelegate>((act) => { return(new BestHTTP.WebSocket.OnWebSocketErrorDescriptionDelegate((webSocket, reason) => { ((Action <BestHTTP.WebSocket.WebSocket, string>)act)(webSocket, reason); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int32> >((act) => { return(new System.Predicate <System.Int32>((obj) => { return ((Func <System.Int32, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <BestHTTP.OnRequestFinishedDelegate>((act) => { return(new BestHTTP.OnRequestFinishedDelegate((originalRequest, response) => { ((Action <BestHTTP.HTTPRequest, BestHTTP.HTTPResponse>)act)(originalRequest, response); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) => { return(new UnityEngine.Events.UnityAction(() => { //((Action<>)act)(); ((System.Action)act)(); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <DG.Tweening.TweenCallback>((act) => { return(new DG.Tweening.TweenCallback(() => { ((System.Action)act)(); })); }); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.Tab, UnityEngine.EventSystems.PointerEventData>(); appDomain.DelegateManager.RegisterDelegateConvertor <Quick.UI.Tab.PointerTabFunc>((act) => { return(new Quick.UI.Tab.PointerTabFunc((target, eventData) => { ((Action <Quick.UI.Tab, UnityEngine.EventSystems.PointerEventData>)act)(target, eventData); })); }); appDomain.DelegateManager.RegisterFunctionDelegate <System.IO.FileInfo, System.IO.FileInfo, System.Int32>(); appDomain.DelegateManager.RegisterMethodDelegate <System.String>(); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.String> >((act) => { return(new UnityEngine.Events.UnityAction <System.String>((arg0) => { ((Action <System.String>)act)(arg0); })); }); appDomain.DelegateManager.RegisterMethodDelegate <System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <Quick.UI.TabGroup, UnityEngine.EventSystems.PointerEventData>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); appDomain.DelegateManager.RegisterMethodDelegate <System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int32, System.Int32, System.Int32>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Boolean>(); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) => { return(new System.Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance>((obj) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int64> >((act) => { return(new System.Predicate <System.Int64>((obj) => { return ((Func <System.Int64, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterFunctionDelegate <System.Int64, System.Boolean>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Video.VideoPlayer>(); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Video.VideoPlayer.EventHandler>((act) => { return(new UnityEngine.Video.VideoPlayer.EventHandler((source) => { ((Action <UnityEngine.Video.VideoPlayer>)act)(source); })); }); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.Vector2>(); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.Vector2> >((act) => { return(new UnityEngine.Events.UnityAction <UnityEngine.Vector2>((arg0) => { ((Action <UnityEngine.Vector2>)act)(arg0); })); }); appDomain.DelegateManager.RegisterMethodDelegate <System.Single>(); appDomain.DelegateManager.RegisterFunctionDelegate <ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int32>(); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) => { return(new System.Comparison <ILRuntime.Runtime.Intepreter.ILTypeInstance>((x, y) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.IO.FileInfo> >((act) => { return(new System.Comparison <System.IO.FileInfo>((x, y) => { return ((Func <System.IO.FileInfo, System.IO.FileInfo, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Boolean> >((act) => { return(new UnityEngine.Events.UnityAction <System.Boolean>((arg0) => { ((Action <System.Boolean>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Int64> >((act) => { return(new System.Predicate <System.Int64>((obj) => { return ((Func <System.Int64, System.Boolean>)act)(obj); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Comparison <System.Int32> >((act) => { return(new System.Comparison <System.Int32>((x, y) => { return ((Func <System.Int32, System.Int32, System.Int32>)act)(x, y); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Int32> >((act) => { return(new UnityEngine.Events.UnityAction <System.Int32>((arg0) => { ((Action <System.Int32>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Single> >((act) => { return(new UnityEngine.Events.UnityAction <System.Single>((arg0) => { ((Action <System.Single>)act)(arg0); })); }); appDomain.DelegateManager.RegisterDelegateConvertor <System.Converter <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64> >((act) => { return(new System.Converter <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64>((input) => { return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, System.Int64>)act)(input); })); }); appDomain.DelegateManager.RegisterMethodDelegate <System.Int64>(); appDomain.DelegateManager.RegisterMethodDelegate <ETModel.AEvent>(); appDomain.DelegateManager.RegisterMethodDelegate <System.String, System.String>(); appDomain.DelegateManager.RegisterMethodDelegate <UnityEngine.UI.Text>(); CLRBindings.Initialize(appDomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appDomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appDomain); //ILSerial.RegisterILRuntimeCLRRedirection(appDomain); }
/// <summary> /// 注册 跨域继承 /// </summary> /// <param name="adaptor"></param> /// <returns></returns> public IXILRuntime RegisterCrossBindingAdaptor(CrossBindingAdaptor adaptor) { m_AppDomain?.RegisterCrossBindingAdaptor(adaptor); return(this); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, ushort, MemoryStream>(); appdomain.DelegateManager.RegisterMethodDelegate <Session>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <System.String>(); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>(); appdomain.DelegateManager.RegisterDelegateConvertor <global::UIEventListener.VoidDelegate>((act) => { return(new global::UIEventListener.VoidDelegate((go) => { ((Action <UnityEngine.GameObject>)act)(go); })); }); appdomain.DelegateManager.RegisterMethodDelegate <System.Int32>(); appdomain.DelegateManager.RegisterDelegateConvertor <DG.Tweening.TweenCallback>((act) => { return(new DG.Tweening.TweenCallback(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Int32> >((act) => { return(new UnityEngine.Events.UnityAction <System.Int32>((arg0) => { ((Action <System.Int32>)act)(arg0); })); }); appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject, System.Int32>(); appdomain.DelegateManager.RegisterDelegateConvertor <global::UIEventListener.IntDelegate>((act) => { return(new global::UIEventListener.IntDelegate((go, index) => { ((Action <UnityEngine.GameObject, System.Int32>)act)(go, index); })); }); CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }
public IHotUpdateService RegisterCrossBindingAdaptor(CrossBindingAdaptor adaptor) { m_AppDomain?.RegisterCrossBindingAdaptor(adaptor); return(this); }
public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain) { // 注册重定向函数 // 注册委托 appdomain.DelegateManager.RegisterMethodDelegate <List <object> >(); appdomain.DelegateManager.RegisterMethodDelegate <AChannel, System.Net.Sockets.SocketError>(); appdomain.DelegateManager.RegisterMethodDelegate <byte[], int, int>(); appdomain.DelegateManager.RegisterMethodDelegate <IResponse>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, object>(); appdomain.DelegateManager.RegisterMethodDelegate <Session, byte, ushort, MemoryStream>(); appdomain.DelegateManager.RegisterMethodDelegate <Session>(); appdomain.DelegateManager.RegisterMethodDelegate <ILTypeInstance>(); appdomain.DelegateManager.RegisterFunctionDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); appdomain.DelegateManager.RegisterMethodDelegate <Google.Protobuf.Adapt_IMessage.Adaptor>(); // 注意: 需要注册重定向函数需要在执行CLRBindings.Initialize前定义 #region 注册 FairyGUI appdomain.DelegateManager.RegisterFunctionDelegate <FairyGUI.GComponent>(); appdomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.UIObjectFactory.GComponentCreator>((act) => { return(new FairyGUI.UIObjectFactory.GComponentCreator(() => { return ((Func <FairyGUI.GComponent>)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.EventCallback0>((act) => { return(new FairyGUI.EventCallback0(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <ETModel.DoHideAnimationEvent>((act) => { return(new ETModel.DoHideAnimationEvent(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.PlayCompleteCallback>((act) => { return(new FairyGUI.PlayCompleteCallback(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <ETModel.DoShowAnimationEvent>((act) => { return(new ETModel.DoShowAnimationEvent(() => { ((Action)act)(); })); }); appdomain.DelegateManager.RegisterDelegateConvertor <ETModel.OnHideEvent>((act) => { return(new ETModel.OnHideEvent(() => { ((Action)act)(); })); }); #endregion // 进行初始化 CLRBindings.Initialize(appdomain); // 注册适配器 Assembly assembly = typeof(Init).Assembly; foreach (Type type in assembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor; if (adaptor == null) { continue; } appdomain.RegisterCrossBindingAdaptor(adaptor); } LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain); }