ILHelper.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Net;
  5. using System.Reflection;
  6. using ILRuntime.CLR.Method;
  7. using ILRuntime.CLR.TypeSystem;
  8. using ILRuntime.Runtime.Enviorment;
  9. using ILRuntime.Runtime.Generated;
  10. using ILRuntime.Runtime.Intepreter;
  11. using UnityEngine;
  12. namespace ET
  13. {
  14. public static class ILHelper
  15. {
  16. public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
  17. {
  18. // 注册重定向函数
  19. // 注册委托
  20. appdomain.DelegateManager.RegisterMethodDelegate<List<object>>();
  21. appdomain.DelegateManager.RegisterMethodDelegate<object>();
  22. appdomain.DelegateManager.RegisterMethodDelegate<bool>();
  23. appdomain.DelegateManager.RegisterMethodDelegate<string>();
  24. appdomain.DelegateManager.RegisterMethodDelegate<float>();
  25. appdomain.DelegateManager.RegisterMethodDelegate<long, int>();
  26. appdomain.DelegateManager.RegisterMethodDelegate<long, MemoryStream>();
  27. appdomain.DelegateManager.RegisterMethodDelegate<long, IPEndPoint>();
  28. appdomain.DelegateManager.RegisterMethodDelegate<ILTypeInstance>();
  29. appdomain.DelegateManager.RegisterFunctionDelegate<UnityEngine.Events.UnityAction>();
  30. appdomain.DelegateManager.RegisterFunctionDelegate<System.Object, ET.ETTask>();
  31. appdomain.DelegateManager.RegisterFunctionDelegate<ILTypeInstance, bool>();
  32. appdomain.DelegateManager.RegisterFunctionDelegate<System.Collections.Generic.KeyValuePair<System.String, System.Int32>, System.String>();
  33. appdomain.DelegateManager.RegisterFunctionDelegate<System.Collections.Generic.KeyValuePair<System.Int32, System.Int32>, System.Boolean>();
  34. appdomain.DelegateManager.RegisterFunctionDelegate<System.Collections.Generic.KeyValuePair<System.String, System.Int32>, System.Int32>();
  35. appdomain.DelegateManager.RegisterFunctionDelegate<List<int>, int>();
  36. appdomain.DelegateManager.RegisterFunctionDelegate<List<int>, bool>();
  37. appdomain.DelegateManager.RegisterFunctionDelegate<int, bool>();//Linq
  38. appdomain.DelegateManager.RegisterFunctionDelegate<int, int, int>();//Linq
  39. appdomain.DelegateManager.RegisterFunctionDelegate<KeyValuePair<int, List<int>>, bool>();
  40. appdomain.DelegateManager.RegisterFunctionDelegate<KeyValuePair<int, int>, KeyValuePair<int, int>, int>();
  41. // 注册适配器
  42. RegisterAdaptor(appdomain);
  43. //LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(appdomain);
  44. CLRBindings.Initialize(appdomain);
  45. }
  46. public static void RegisterAdaptor(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
  47. {
  48. //注册自己写的适配器
  49. appdomain.RegisterCrossBindingAdaptor(new IAsyncStateMachineClassInheritanceAdaptor());
  50. appdomain.RegisterCrossBindingAdaptor(new ISupportInitializeAdapter());
  51. }
  52. }
  53. }