private EventCallbackList GetCallbackListForWriting()
        {
            EventCallbackList result;

            if (this.m_IsInvoking > 0)
            {
                if (this.m_TemporaryCallbacks == null)
                {
                    if (this.m_Callbacks != null)
                    {
                        this.m_TemporaryCallbacks = EventCallbackRegistry.GetCallbackList(this.m_Callbacks);
                    }
                    else
                    {
                        this.m_TemporaryCallbacks = EventCallbackRegistry.GetCallbackList(null);
                    }
                }
                result = this.m_TemporaryCallbacks;
            }
            else
            {
                if (this.m_Callbacks == null)
                {
                    this.m_Callbacks = EventCallbackRegistry.GetCallbackList(null);
                }
                result = this.m_Callbacks;
            }
            return(result);
        }
 public void InvokeCallbacks(EventBase evt)
 {
     if (this.m_Callbacks != null)
     {
         this.m_IsInvoking++;
         for (int i = 0; i < this.m_Callbacks.Count; i++)
         {
             if (evt.isImmediatePropagationStopped)
             {
                 break;
             }
             this.m_Callbacks[i].Invoke(evt);
         }
         this.m_IsInvoking--;
         if (this.m_IsInvoking == 0)
         {
             if (this.m_TemporaryCallbacks != null)
             {
                 EventCallbackRegistry.ReleaseCallbackList(this.m_Callbacks);
                 this.m_Callbacks = EventCallbackRegistry.GetCallbackList(this.m_TemporaryCallbacks);
                 EventCallbackRegistry.ReleaseCallbackList(this.m_TemporaryCallbacks);
                 this.m_TemporaryCallbacks = null;
             }
         }
     }
 }
 public void RegisterCallback <TEventType>(EventCallback <TEventType> callback, Capture useCapture = Capture.NoCapture) where TEventType : EventBase <TEventType>, new()
 {
     if (this.m_CallbackRegistry == null)
     {
         this.m_CallbackRegistry = new EventCallbackRegistry();
     }
     this.m_CallbackRegistry.RegisterCallback <TEventType>(callback, useCapture);
 }
Esempio n. 4
0
        public void RegisterCallback <TEventType, TUserArgsType>(EventCallback <TEventType, TUserArgsType> callback, TUserArgsType userArgs, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEventType : EventBase <TEventType>, new()
        {
            if (m_CallbackRegistry == null)
            {
                m_CallbackRegistry = new EventCallbackRegistry();
            }

            m_CallbackRegistry.RegisterCallback <TEventType, TUserArgsType>(callback, userArgs, useTrickleDown);
        }
        public void RegisterCallback <TEventType, TUserArgsType>(EventCallback <TEventType, TUserArgsType> callback, TUserArgsType userArgs, Capture useCapture = Capture.NoCapture) where TEventType : EventBase <TEventType>, new()
        {
            if (m_CallbackRegistry == null)
            {
                m_CallbackRegistry = new EventCallbackRegistry();
            }

            m_CallbackRegistry.RegisterCallback <TEventType, TUserArgsType>(callback, userArgs, useCapture);
        }