Example #1
0
 /// <summary>
 /// Calls all the execution strategies exposed by the list of <see cref="IEventSubscription"/>.
 /// </summary>
 /// <param name="publisherAddress">Specfied publisher address, can be null</param>
 /// <param name="arguments">The arguments that will be passed to the listeners.</param>
 /// <remarks>Before executing the strategies, this class will prune all the subscribers from the
 /// list that return a <see langword="null" /> <see cref="Action{T}"/> when calling the
 /// <see cref="IEventSubscription.GetExecutionStrategy"/> method.</remarks>
 protected virtual void InternalPublish(EventCommunicatorAddress publisherAddress, EventCommunicatorsRelationship publishTo, params object[] arguments)
 {
     List<Action<object[]>> executionStrategies = pruneAndReturnStrategies(publisherAddress, publishTo);
     foreach (var executionStrategy in executionStrategies)
     {
         executionStrategy(arguments);
     }
 }
Example #2
0
        private List<Action<object[]>> pruneAndReturnStrategies(EventCommunicatorAddress publisherAddress, EventCommunicatorsRelationship publishTo)
        {
            var returnList = new List<Action<object[]>>();

            lock (Subscriptions)
            {
                for (var i = Subscriptions.Count - 1; i >= 0; i--)
                {
                    Action<object[]> listItem =
                        _subscriptions[i].GetExecutionStrategy(publisherAddress, publishTo);

                    if (listItem == null)
                    {
                        // Prune from main list. Log?
                        _subscriptions.RemoveAt(i);
                    }
                    else
                    {
                        returnList.Add(listItem);
                    }
                }
            }

            return returnList;
        }
        private void subscribeToEvent(EventCommunicatorsRelationship relationship)
        {
            var msg = _eventAggregator.GetEvent<Event<MockEventForChildCommunicator>>();

            msg.Subscribe(x => LastPublishedEvent = x, this, relationship);
        }
 public Action<object[]> GetExecutionStrategy(EventCommunicatorAddress publisherAddress, EventCommunicatorsRelationship publishTo)
 {
     return GetExecutionStrategy();
 }
        private void publishToEvent(EventCommunicatorsRelationship relationship)
        {
            var msg = _eventAggregator.GetEvent<Event<MockEventForChildCommunicator>>();

            msg.Publish(this, new MockEventForChildCommunicator(this), relationship);
        }