コード例 #1
0
        private void NotifyListeners(Event evt, Func <string, IList <Listener> > listenersFn)
        {
            evt.CurrentTarget = _target;
            lock (_getLockObject())
            {
                var listeners = listenersFn(evt.Type);
                // ReSharper disable once ForCanBeConvertedToForeach, to avoid 'collection was modified' exception
                for (var i = 0; i < listeners.Count; i++)
                {
                    var listener = listeners[i];
                    if (listener.Options != null && listener.Options.Passive)
                    {
                        evt.PreventDefaultDeprecated = true;
                    }

                    try
                    {
                        listener.Handler(evt);
                    }
                    catch (Exception e)
                    {
                        HandlerException?.Invoke(e);
                    }
                    finally
                    {
                        evt.PreventDefaultDeprecated = false;
                    }

                    if (listener.Options != null && listener.Options.Once)
                    {
                        RemoveEventListener(evt.Type, listener.Handler, listener.Options);
                    }
                }
            }
        }
コード例 #2
0
 public void OnHandlerException(object sender, HandlerExceptionEventArgs args)
 {
     HandlerException.Invoke(sender, args);
 }