Esempio n. 1
0
        private void AttachListner(uint eventKey, ArrayList listenerList, IEventListener listener)
        {
            int pos = 0;

            for (int n = 0; n < listenerList.Count; n++)
            {
                // the one last added gains the least priority
                if (listener.GetListenerPriority(eventKey) > (listenerList[n] as IEventListener).GetListenerPriority(eventKey))
                {
                    break;
                }
                pos++;
            }
            listenerList.Insert(pos, listener);
        }
Esempio n. 2
0
    private void _AttachListner(uint eventKey, List <WeakReference> listenerList, IEventListener listener)
    {
        int pos = 0;

        for (int n = 0; n < listenerList.Count; n++)
        {
            IEventListener tmp = listenerList[n].Target as IEventListener;

            if (tmp == null)
            {
                pos++;
                continue;
            }

            if (listener.GetListenerPriority(eventKey) > tmp.GetListenerPriority(eventKey))
            {
                break;
            }
            pos++;
        }
        listenerList.Insert(pos, new WeakReference(listener, false));
    }
Esempio n. 3
0
        void _AttachListener(IEventListener listener, uint eventKey)
        {
            if (listener == null)
            {
                Log.Error("EventDispacher.AttachListenerNow: failed due to no listener or event key specified.");
                return;
            }

            if (System.Threading.Thread.CurrentThread.ManagedThreadId != 1)
            {
                Log.Debug("EventDispacher.AttachListenerNow: " + eventKey);
            }
            if (!_listenerHs.ContainsKey(eventKey))
            {
                _listenerHs.Add(eventKey, new ArrayList());
            }

            ArrayList listenerList = _listenerHs[eventKey] as ArrayList;

            if (listenerList.Contains(listener))
            {
                Log.Error("EventDispacher.AttachListenerNow: " + listener.GetType().ToString() + " is already in list for event: " + eventKey.ToString());
                return;
            }

            int pos = 0;

            for (int n = 0; n < listenerList.Count; n++)
            {
                if (listener.GetListenerPriority(eventKey) > (listenerList[n] as IEventListener).GetListenerPriority(eventKey))
                {
                    break;
                }
                pos++;
            }
            listenerList.Insert(pos, listener);
        }