Exemple #1
0
        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);
        }
    private void InitDelegates()
    {
        ILRegType.RegisterFunctionDelegate(appdomain);

        appdomain.DelegateManager.RegisterMethodDelegate <System.String>();
        appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>();

        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.Threading.ThreadStart>((act) =>
        {
            return(new System.Threading.ThreadStart(() =>
            {
                ((Action)act)();
            }));
        });
        appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>();
        appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode> >((act) =>
        {
            return(new UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>((arg0, arg1) =>
            {
                ((Action <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>)act)(arg0, arg1);
            }));
        });
        appdomain.DelegateManager.RegisterMethodDelegate <System.String, System.String, UnityEngine.LogType>();
        appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Application.LogCallback>((act) =>
        {
            return(new UnityEngine.Application.LogCallback((condition, stackTrace, type) =>
            {
                ((Action <System.String, System.String, UnityEngine.LogType>)act)(condition, stackTrace, type);
            }));
        });
        appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) =>
        {
            return(new UnityEngine.Events.UnityAction(() =>
            {
                ((Action)act)();
            }));
        });
    }
Exemple #3
0
 private static void InitDelegates(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
 {
     ILRegType.RegisterFunctionDelegate(appdomain);
     ILRegType.RegisterDelegateConvertor(appdomain);
     ILRegType.RegisterMethodDelegate(appdomain);
 }
    private void InitDelegates()
    {
        ILRegType.RegisterFunctionDelegate(appdomain);

        #region WebSocket相关
        appdomain.DelegateManager.RegisterMethodDelegate <System.Object, System.EventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor <System.EventHandler>((act) =>
        {
            return(new System.EventHandler((sender, e) =>
            {
                ((Action <System.Object, System.EventArgs>)act)(sender, e);
            }));
        });
        appdomain.DelegateManager.RegisterMethodDelegate <System.Object, WebSocketSharp.MessageEventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor <System.EventHandler <WebSocketSharp.MessageEventArgs> >((act) =>
        {
            return(new System.EventHandler <WebSocketSharp.MessageEventArgs>((sender, e) =>
            {
                ((Action <System.Object, WebSocketSharp.MessageEventArgs>)act)(sender, e);
            }));
        });
        appdomain.DelegateManager.RegisterMethodDelegate <System.Object, WebSocketSharp.ErrorEventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor <System.EventHandler <WebSocketSharp.ErrorEventArgs> >((act) =>
        {
            return(new System.EventHandler <WebSocketSharp.ErrorEventArgs>((sender, e) =>
            {
                ((Action <System.Object, WebSocketSharp.ErrorEventArgs>)act)(sender, e);
            }));
        });
        appdomain.DelegateManager.RegisterMethodDelegate <System.Object, WebSocketSharp.CloseEventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor <System.EventHandler <WebSocketSharp.CloseEventArgs> >((act) =>
        {
            return(new System.EventHandler <WebSocketSharp.CloseEventArgs>((sender, e) =>
            {
                ((Action <System.Object, WebSocketSharp.CloseEventArgs>)act)(sender, e);
            }));
        });



        #endregion

        appdomain.DelegateManager.RegisterMethodDelegate <global::IDisposableAdapter.Adaptor>();
        appdomain.DelegateManager.RegisterFunctionDelegate <System.Threading.Tasks.Task>();
        appdomain.DelegateManager.RegisterMethodDelegate <ILRuntime.Runtime.Intepreter.ILTypeInstance>();

        appdomain.DelegateManager.RegisterFunctionDelegate <System.Reflection.MethodInfo, System.Boolean>();
        appdomain.DelegateManager.RegisterDelegateConvertor <System.Predicate <System.Reflection.MethodInfo> >((act) =>
        {
            return(new System.Predicate <System.Reflection.MethodInfo>((obj) =>
            {
                return ((Func <System.Reflection.MethodInfo, System.Boolean>)act)(obj);
            }));
        });

        appdomain.DelegateManager.RegisterMethodDelegate <System.IAsyncResult>();

        appdomain.DelegateManager.RegisterMethodDelegate <System.Object, System.UnhandledExceptionEventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor <System.UnhandledExceptionEventHandler>((act) =>
        {
            return(new System.UnhandledExceptionEventHandler((sender, e) =>
            {
                ((Action <System.Object, System.UnhandledExceptionEventArgs>)act)(sender, e);
            }));
        });

        appdomain.DelegateManager.RegisterMethodDelegate <ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance>();
        appdomain.DelegateManager.RegisterMethodDelegate <System.Object>();
        appdomain.DelegateManager.RegisterDelegateConvertor <System.Threading.WaitCallback>((act) =>
        {
            return(new System.Threading.WaitCallback((state) =>
            {
                ((Action <System.Object>)act)(state);
            }));
        });

        appdomain.DelegateManager.RegisterMethodDelegate <System.Boolean>();
        appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <System.Boolean> >((act) =>
        {
            return(new UnityEngine.Events.UnityAction <System.Boolean>((arg0) =>
            {
                ((Action <System.Boolean>)act)(arg0);
            }));
        });

        appdomain.DelegateManager.RegisterMethodDelegate <System.String>();
        appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.GameObject>();

        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.Threading.ThreadStart>((act) =>
        {
            return(new System.Threading.ThreadStart(() =>
            {
                ((Action)act)();
            }));
        });
        appdomain.DelegateManager.RegisterMethodDelegate <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>();
        appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode> >((act) =>
        {
            return(new UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>((arg0, arg1) =>
            {
                ((Action <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>)act)(arg0, arg1);
            }));
        });
        appdomain.DelegateManager.RegisterMethodDelegate <System.String, System.String, UnityEngine.LogType>();
        appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Application.LogCallback>((act) =>
        {
            return(new UnityEngine.Application.LogCallback((condition, stackTrace, type) =>
            {
                ((Action <System.String, System.String, UnityEngine.LogType>)act)(condition, stackTrace, type);
            }));
        });
        appdomain.DelegateManager.RegisterDelegateConvertor <UnityEngine.Events.UnityAction>((act) =>
        {
            return(new UnityEngine.Events.UnityAction(() =>
            {
                ((Action)act)();
            }));
        });
    }
Exemple #5
0
    private void InitDelegates()
    {
        ILRegType.RegisterFunctionDelegate(appdomain);

        #region WebSocket相关
        appdomain.DelegateManager.RegisterMethodDelegate<System.Object, System.EventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor<System.EventHandler>((act) =>
        {
            return new System.EventHandler((sender, e) =>
            {
                ((Action<System.Object, System.EventArgs>)act)(sender, e);
            });
        });
        appdomain.DelegateManager.RegisterMethodDelegate<System.Object, WebSocketSharp.MessageEventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor<System.EventHandler<WebSocketSharp.MessageEventArgs>>((act) =>
        {
            return new System.EventHandler<WebSocketSharp.MessageEventArgs>((sender, e) =>
            {
                ((Action<System.Object, WebSocketSharp.MessageEventArgs>)act)(sender, e);
            });
        });
        appdomain.DelegateManager.RegisterMethodDelegate<System.Object, WebSocketSharp.ErrorEventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor<System.EventHandler<WebSocketSharp.ErrorEventArgs>>((act) =>
        {
            return new System.EventHandler<WebSocketSharp.ErrorEventArgs>((sender, e) =>
            {
                ((Action<System.Object, WebSocketSharp.ErrorEventArgs>)act)(sender, e);
            });
        });
        appdomain.DelegateManager.RegisterMethodDelegate<System.Object, WebSocketSharp.CloseEventArgs>();
        appdomain.DelegateManager.RegisterDelegateConvertor<System.EventHandler<WebSocketSharp.CloseEventArgs>>((act) =>
        {
            return new System.EventHandler<WebSocketSharp.CloseEventArgs>((sender, e) =>
            {
                ((Action<System.Object, WebSocketSharp.CloseEventArgs>)act)(sender, e);
            });
        });
        #endregion
        appdomain.DelegateManager.RegisterMethodDelegate<System.String>();
        appdomain.DelegateManager.RegisterMethodDelegate<UnityEngine.GameObject>();
        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.Threading.ThreadStart>((act) =>
        {
            return new System.Threading.ThreadStart(() =>
            {
                ((Action)act)();
            });
        });
        appdomain.DelegateManager.RegisterMethodDelegate<UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>();
        appdomain.DelegateManager.RegisterDelegateConvertor<UnityEngine.Events.UnityAction<UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>>((act) =>
        {
            return new UnityEngine.Events.UnityAction<UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>((arg0, arg1) =>
            {
                ((Action<UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>)act)(arg0, arg1);
            });
        });
        appdomain.DelegateManager.RegisterMethodDelegate<System.String, System.String, UnityEngine.LogType>();
        appdomain.DelegateManager.RegisterDelegateConvertor<UnityEngine.Application.LogCallback>((act) =>
        {
            return new UnityEngine.Application.LogCallback((condition, stackTrace, type) =>
            {
                ((Action<System.String, System.String, UnityEngine.LogType>)act)(condition, stackTrace, type);
            });
        });
        appdomain.DelegateManager.RegisterDelegateConvertor<UnityEngine.Events.UnityAction>((act) =>
        {
            return new UnityEngine.Events.UnityAction(() =>
            {
                ((Action)act)();
            });
        });