| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 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 ProtoBuf;
- 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>();
-
- appdomain.DelegateManager.RegisterDelegateConvertor<UnityEngine.Events.UnityAction>((act) =>
- {
- return new UnityEngine.Events.UnityAction(() =>
- {
- ((Action)act)();
- });
- });
-
- appdomain.DelegateManager.RegisterDelegateConvertor<Comparison<KeyValuePair<int, int>>>((act) =>
- {
- return new Comparison<KeyValuePair<int, int>>((x, y) =>
- {
- return ((Func<KeyValuePair<int, int>, KeyValuePair<int, int>, int>)act)(x, y);
- });
- });
-
- // 注册适配器
- RegisterAdaptor(appdomain);
-
- //注册Json的CLR
- LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain);
- //注册ProtoBuf的CLR
- PType.RegisterILRuntimeCLRRedirection(appdomain);
-
-
- CLRBindings.Initialize(appdomain);
- }
-
- public static void RegisterAdaptor(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
- {
- //注册自己写的适配器
- appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor());
- }
- }
- }
|