示例#1
0
 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);
            }
        }
示例#3
0
        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);
            }
        }
示例#5
0
 public void Invoke(EventPublication publication)
 {
     _handler((TPayload)publication.Payload);
 }
示例#6
0
 public bool Matches(EventPublication publication)
 {
     return
         ((Event == AnyEvent || publication.Event == _event) &&
          _conditions.All(x => x.IsTrue(publication.Payload)));
 }