Exemplo n.º 1
0
        public void RegisterCallback <TEventType, TCallbackArgs>(EventCallback <TEventType, TCallbackArgs> callback, TCallbackArgs userArgs, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEventType : EventBase <TEventType>, new()
        {
            if (callback == null)
            {
                throw new ArgumentException("callback parameter is null");
            }

            long eventTypeId = EventBase <TEventType> .TypeId();

            var callbackPhase = useTrickleDown == TrickleDown.TrickleDown ? CallbackPhase.TrickleDownAndTarget : CallbackPhase.TargetAndBubbleUp;

            EventCallbackList callbackList = GetCallbackListForReading();

            if (callbackList != null)
            {
                var functor = callbackList.Find(eventTypeId, callback, callbackPhase) as EventCallbackFunctor <TEventType, TCallbackArgs>;
                if (functor != null)
                {
                    functor.userArgs = userArgs;
                    return;
                }
            }
            callbackList = GetCallbackListForWriting();
            callbackList.Add(new EventCallbackFunctor <TEventType, TCallbackArgs>(callback, userArgs, callbackPhase));
        }
        public void RegisterCallback <TEventType, TCallbackArgs>(EventCallback <TEventType, TCallbackArgs> callback, TCallbackArgs userArgs, Capture useCapture = Capture.NoCapture) where TEventType : EventBase <TEventType>, new()
        {
            long eventTypeId = EventBase <TEventType> .TypeId();

            CallbackPhase phase = (useCapture != Capture.Capture) ? CallbackPhase.TargetAndBubbleUp : CallbackPhase.CaptureAndTarget;

            if (this.ShouldRegisterCallback(eventTypeId, callback, phase))
            {
                EventCallbackList callbackListForWriting = this.GetCallbackListForWriting();
                callbackListForWriting.Add(new EventCallbackFunctor <TEventType, TCallbackArgs>(callback, userArgs, phase));
            }
        }
        public void RegisterCallback <TEventType, TCallbackArgs>(EventCallback <TEventType, TCallbackArgs> callback, TCallbackArgs userArgs, Capture useCapture = Capture.NoCapture) where TEventType : EventBase <TEventType>, new()
        {
            long eventTypeId = EventBase <TEventType> .TypeId();

            var callbackPhase = useCapture == Capture.Capture ? CallbackPhase.CaptureAndTarget : CallbackPhase.TargetAndBubbleUp;

            if (ShouldRegisterCallback(eventTypeId, callback, callbackPhase))
            {
                EventCallbackList callbackList = GetCallbackListForWriting();
                callbackList.Add(new EventCallbackFunctor <TEventType, TCallbackArgs>(callback, userArgs, callbackPhase));
            }
        }
Exemplo n.º 4
0
        public void RegisterCallback <TEventType>(EventCallback <TEventType> callback, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEventType : EventBase <TEventType>, new()
        {
            if (callback == null)
            {
                throw new ArgumentException("callback parameter is null");
            }

            long eventTypeId = EventBase <TEventType> .TypeId();

            var callbackPhase = useTrickleDown == TrickleDown.TrickleDown ? CallbackPhase.TrickleDownAndTarget : CallbackPhase.TargetAndBubbleUp;

            EventCallbackList callbackList = GetCallbackListForReading();

            if (callbackList == null || callbackList.Contains(eventTypeId, callback, callbackPhase) == false)
            {
                callbackList = GetCallbackListForWriting();
                callbackList.Add(new EventCallbackFunctor <TEventType>(callback, callbackPhase));
            }
        }