private void HandleEvent <TEvent>(TEvent @event) where TEvent : IEvent { if (EventSubscriberProvider != null) { var eventSubscriberTypes = EventSubscriberProvider.GetHandlerTypes(@event.GetType()); eventSubscriberTypes.ForEach(eventSubscriberType => { var eventSubscriber = Container.Resolve(eventSubscriberType.Type); ((dynamic)eventSubscriber).Handle((dynamic)@event); }); } }
public void Publish <TEvent>(TEvent @event) where TEvent : IEvent { EventQueue.Add(@event); if (EventSubscriberProvider != null) { var eventSubscriberTypes = EventSubscriberProvider.GetHandlerTypes(@event.GetType()); eventSubscriberTypes.ForEach(eventSubscriberType => { var eventSubscriber = Container.Resolve(eventSubscriberType.Type); ((dynamic)eventSubscriber).Handle((dynamic)@event); }); } }