IEnumerable <IEventSubscription> IEventSubscriptionRepository.GetSubscriptions( EventPublication publication ) { return(_subscriptionStores .SelectMany(x => x.Subscriptions) .Where(x => x.Matches(publication)) .ToArray()); }
void IEvent <TArgs> .Publish( IEventSubscriptionRepository allSubscriptions, TArgs payload ) { var publication = new EventPublication(this, payload); foreach (TTarget node in GetHierarchyNodes(payload.Target)) { PublishToSingleNode(allSubscriptions, node, publication); } }
void IEvent <TPayload> .Publish(IEventSubscriptionRepository allSubscriptions, TPayload payload) { var publication = new EventPublication(this, payload); IEnumerable <IEventSubscription> matching = allSubscriptions .GetSubscriptions(publication) .OrderBy(x => x.ExecutionOrder); foreach (var subscription in matching) { subscription.Invoke(publication); } }
private void PublishToSingleNode( IEventSubscriptionRepository allSubscriptions, TTarget node, EventPublication publication ) { IEnumerable <IEventSubscription> matching = allSubscriptions .GetSubscriptions(publication) .OfType <IHierarchicalEventSubscription <TTarget> >() .Where(s => Object.ReferenceEquals(s.Target, node)) .OrderBy(x => x.ExecutionOrder); foreach (var subscription in matching) { subscription.Invoke(publication); } }
public void Invoke(EventPublication publication) { _handler((TPayload)publication.Payload); }
public bool Matches(EventPublication publication) { return ((Event == AnyEvent || publication.Event == _event) && _conditions.All(x => x.IsTrue(publication.Payload))); }