|
|
@@ -0,0 +1,63 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
+using System.Net;
|
|
|
+using System.Reflection;
|
|
|
+using ILRuntime.CLR.Method;
|
|
|
+using ILRuntime.CLR.TypeSystem;
|
|
|
+using ILRuntime.Runtime.Enviorment;
|
|
|
+using ILRuntime.Runtime.Generated;
|
|
|
+using ILRuntime.Runtime.Intepreter;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+namespace ET
|
|
|
+{
|
|
|
+ public static class ILHelper
|
|
|
+ {
|
|
|
+ public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
|
|
|
+ {
|
|
|
+
|
|
|
+ // 注册重定向函数
|
|
|
+
|
|
|
+ // 注册委托
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<List<object>>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<object>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<bool>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<string>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<float>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<long, int>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<long, MemoryStream>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<long, IPEndPoint>();
|
|
|
+ appdomain.DelegateManager.RegisterMethodDelegate<ILTypeInstance>();
|
|
|
+
|
|
|
+
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<UnityEngine.Events.UnityAction>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<System.Object, ET.ETTask>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<ILTypeInstance, bool>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<System.Collections.Generic.KeyValuePair<System.String, System.Int32>, System.String>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<System.Collections.Generic.KeyValuePair<System.Int32, System.Int32>, System.Boolean>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<System.Collections.Generic.KeyValuePair<System.String, System.Int32>, System.Int32>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<List<int>, int>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<List<int>, bool>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<int, bool>();//Linq
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<int, int, int>();//Linq
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<KeyValuePair<int, List<int>>, bool>();
|
|
|
+ appdomain.DelegateManager.RegisterFunctionDelegate<KeyValuePair<int, int>, KeyValuePair<int, int>, int>();
|
|
|
+
|
|
|
+ // 注册适配器
|
|
|
+ RegisterAdaptor(appdomain);
|
|
|
+
|
|
|
+ //LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain);
|
|
|
+
|
|
|
+ CLRBindings.Initialize(appdomain);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void RegisterAdaptor(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
|
|
|
+ {
|
|
|
+ //注册自己写的适配器
|
|
|
+ appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor());
|
|
|
+ appdomain.RegisterCrossBindingAdaptor(new ISupportInitializeAdapter());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|