Ejemplo n.º 1
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);
            }
        }