22 var currentContext = context;
23 while (currentContext != null) {
25 var scope = (IEventScope) currentContext;
26 scope.EventRegistry.RegisterEvent(@event);
29 currentContext = currentContext.
Parent;
34 var currentContext = context;
35 while (currentContext != null) {
37 currentContext.RegisterInstance(router);
41 currentContext = currentContext.
Parent;
45 public static void Route<TEvent>(
this IContext context, Action<TEvent> router)
46 where TEvent :
class,
IEvent {
47 context.Route(router, null);
50 public static void Route<TEvent>(
this IContext context, Action<TEvent> router, Func<TEvent, bool> condition)
51 where TEvent :
class,
IEvent {
55 #region DelegatedRouter
63 this.condition = condition;
66 protected override void Consume(TEvent message) {
71 if (!(@event is TEvent))
74 if (condition == null)
77 return condition((TEvent)@event);
static void RegisterEvent(this IContext context, IEvent @event)
void RouteEvent(IEvent e)
Routes the input event to the final destination.
This is an event occurred during the lifetime of a database.
override void Consume(TEvent message)
DelegateRouter(Action< TEvent > route, Func< TEvent, bool > condition)
static void AttachRouter(this IContext context, IEventRouter router)
Func< TEvent, bool > condition
bool CanRoute(IEvent @event)
Defines the basic logic for the dispatching of events within a system workflow.