public void Publish <TEvent>(TEvent @event) where TEvent : class, IEvent { if (@event == null) { throw new ArgumentNullException("@event"); } foreach (var listener in _listeners .Cast <dynamic>() .Where(listener => CanHandle <TEvent>(listener))) { listener.Handle(@event); } }