Exemplo n.º 1
0
        public void Dump(MainLoopEvent mainloopevent)
        {
#if UNITY_EDITOR
            var en = this.callbackMap.GetEnumerator();
            while (en.MoveNext())
            {
                Action <object, int> act = en.Current.Value;
                if (act != null && callbackListMap[en.Current.Key].Count > 0)
                {
                    System.Delegate d         = act as System.Delegate;
                    Delegate[]      delegates = d.GetInvocationList();
                    for (int i = 0; i < delegates.Length; ++i)
                    {
                        LogMgr.LogWarningFormat(" InstanceCacheDelegate {0} in {1} not clear at {2}", delegates[i].Method.Name, delegates[i].Method.DeclaringType, mainloopevent);
                    }
                }
            }

            var listen = this.callbackListMap.GetEnumerator();
            while (listen.MoveNext())
            {
                List <object> list = listen.Current.Value;
                if (list != null && list.Count > 0)
                {
                    for (int i = 0; i < list.Count; ++i)
                    {
                        object o = list[i];
                        LogMgr.LogWarningFormat("InstanceCacheDelegate {0} not clear at {1}", o, mainloopevent);
                    }
                }
            }
#endif
        }
Exemplo n.º 2
0
        private void _tryCall(MainLoopEvent em, int val = -1)
        {
            try
            {
                int e = (int)em;

                if (this.methodDic.ContainsKey(e))
                {
                    this.methodDic[e].Invoke(val);
                }

                if (eventList.ContainsKey(e))
                {
                    Action <int> callback = eventList[e];
                    if (callback != null)
                    {
                        if (FrameWorkConfig.Open_DEBUG)
                        {
                            var list = callback.GetInvocationList();
                            for (int i = 0; i < list.Length; ++i)
                            {
                                list[i].DynamicInvoke(val);
                            }
                        }
                        else
                        {
                            if (callback != null)
                            {
                                callback(val);
                            }
                        }
                    }
                    else
                    {
                        eventList.Remove(e);
                    }
                }

                if (this.attEvents.ContainsKey(e))
                {
                    if (attEvents[e] != null)
                    {
                        attEvents[e].Invoke(e);
                    }
                }
            }
            catch (FrameWorkException ex)
            {
                LogMgr.LogException(ex);

                ex.RaiseExcption();
            }
            catch (Exception ex)
            {
                LogMgr.LogException(ex);
            }
        }
Exemplo n.º 3
0
        public bool UnRegisterCachedAction(MainLoopEvent em, int id, System.Object ins)
        {
            int e = (int)em;

            if (this.attEvents.ContainsKey(e))
            {
                InstanceCacheDelegate d = this.attEvents[e];
                return(d.Remove(id, ins));
            }
            return(false);
        }
Exemplo n.º 4
0
        public bool UnRegisterLoopEvent(MainLoopEvent em, Action <int> d)
        {
            int e = (int)em;

            if (eventList.ContainsKey(e))
            {
                this.eventList[e] -= d;
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        public bool UnRegisterLoopEvent(MainLoopEvent em, MethodInfo method)
        {
            int e = (int)em;

            if (eventList.ContainsKey(e))
            {
                this.eventList[e] -= (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), method);
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public bool UnRegisterStaticEvent(MainLoopEvent em, MethodInfo method)
        {
            int e = (int)em;

            if (methodDic.ContainsKey(e))
            {
                Action <int> func = (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), method);
                methodDic[e].Rmove(func);
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        public static void DestroyAttEvent(MainLoopEvent loopevent, Type tp, string methodname)
        {
            MethodInfo method = tp.GetMethod(methodname, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);

            if (method != null)
            {
                MainLoop.getInstance().UnRegisterLoopEvent(loopevent, method);
            }
            else
            {
                LogMgr.LogErrorFormat("cant found {0} in type :{1}", methodname, tp);
            }
        }
Exemplo n.º 8
0
        public void RegisterStaticEvent(MainLoopEvent em, MethodInfo method, int Priority = 0)
        {
            int          e    = (int)em;
            Action <int> func = (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), method);

            if (this.methodDic.ContainsKey(e))
            {
                this.methodDic[e].Add(func, Priority);
            }
            else
            {
                StaticDelegate d = new StaticDelegate();
                d.Add(func, Priority);
                this.methodDic.Add(e, d);
            }
        }
Exemplo n.º 9
0
        public void RegisterCachedAction(MainLoopEvent em, int id, System.Object ins)
        {
            int e = (int)em;

            if (this.attEvents.ContainsKey(e))
            {
                InstanceCacheDelegate d = this.attEvents[e];
                d.Add(id, ins);
            }
            else
            {
                InstanceCacheDelegate d = new InstanceCacheDelegate();
                d.Add(id, ins);
                this.attEvents.Add(e, d);
            }
        }
Exemplo n.º 10
0
        public void PreRegisterCachedAction(MainLoopEvent em, Action <System.Object, int> act)
        {
            int e = (int)em;

            if (this.attEvents.ContainsKey(e))
            {
                InstanceCacheDelegate d = this.attEvents[e];
                d.PreAdd(act);
            }
            else
            {
                InstanceCacheDelegate d = new InstanceCacheDelegate();
                d.PreAdd(act);
                this.attEvents.Add(e, d);
            }
        }
Exemplo n.º 11
0
        public void Dump(MainLoopEvent mainloopevent)
        {
#if UNITY_EDITOR
            var en = this.cachesMap.GetEnumerator();
            while (en.MoveNext())
            {
                Action <int> act = en.Current.Value;
                if (act != null)
                {
                    System.Delegate d         = act as System.Delegate;
                    Delegate[]      delegates = d.GetInvocationList();
                    for (int i = 0; i < delegates.Length; ++i)
                    {
                        LogMgr.LogWarningFormat(" StaticDelegate {0} in {1} not clear at:{2}", delegates[i].Method.Name, delegates[i].Method.DeclaringType, mainloopevent);
                    }
                }
            }
#endif
        }
Exemplo n.º 12
0
        public void RegisterLoopEvent(MainLoopEvent em, Action <int> d, bool first = false)
        {
            int e = (int)em;

            if (eventList.ContainsKey(e))
            {
                if (!first)
                {
                    this.eventList[e] += d;
                }
                else
                {
                    Action <int> old = this.eventList[e];
                    d += old;
                    this.eventList[e] = d;
                }
            }
            else
            {
                this.eventList[e] = d;
            }
        }
Exemplo n.º 13
0
 public DelegateMethodAttribute(MainLoopEvent ev, string pname, Type passtp)
 {
     this.Invokeopportunity = ev;
     this.name = pname;
     this.tp   = passtp;
 }
Exemplo n.º 14
0
 //
 // This is called once every main loop frame, outside of object context
 //
 internal static void OnMainLoop(ulong frame)
 {
     MainLoopEvent?.Invoke(null, new EventArgs());
 }