public void ConsumeEvent(Event @event) { foreach (IEventHandler handler in eventHandlerProvider.GetEventHandlers(@event.GetType())) { handler.When(@event); } }
protected virtual void When(Event @event) { //Default handler, do nothing }
protected void RaiseEvent(Event @event) { DispatchEvent(@event); Version++; changes.Add(@event); }
protected void ApplyEvent(Event @event) { DispatchEvent(@event); Version++; }
private void DispatchEvent(Event @event) { foreach (var handler in EventRoutes.Where(x => x.HandlerType == @event.GetType())) { handler.Handle(@event); } }
public static void HandleEvent(Event @event) { IEventEmitter eventEmitter = DIExtensions.Container.GetInstance<IEventEmitter>(); eventEmitter.EmitEvent(@event); PersistenceExtensions.OpenTransaction(); DIExtensions.Container.GetInstance<EventDispatcher>().DispatchEvents(); PersistenceExtensions.CommitTransaction(); }
public void EmitEvent(Event @event) { eventsToEmit.Enqueue(@event); }