Ejemplo n.º 1
0
        /// <summary>
        /// Creates the <see cref="INotificationMediator{TNotification}"/> instance.
        /// </summary>
        /// <returns>The <see cref="INotificationMediator{TNotification}"/> instance.</returns>
        public INotificationMediator <TNotification> CreateMqMediator()
        {
            if (_cached == null)
            {
                int publishSize = 0;
                SortedList <ServicingOrder, List <INotificationHandler <TNotification> > > executionPublishSequence = new SortedList <ServicingOrder, List <INotificationHandler <TNotification> > >(_handlers.Count());
                foreach (var item in _handlers)
                {
                    publishSize++;
                    if (executionPublishSequence.ContainsKey(item.OrderInTheGroup))
                    {
                        executionPublishSequence[item.OrderInTheGroup].Add(item);
                    }
                    else
                    {
                        executionPublishSequence[item.OrderInTheGroup] = new List <INotificationHandler <TNotification> >()
                        {
                            item
                        };
                    }
                }
                _cached = new MqPublishMediatorProvider(executionPublishSequence, publishSize);
            }

            return(_cached);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize instance with specifics configuration.
 /// </summary>
 /// <param name="factory">The mediator factory.</param>
 public NotificationMediatorManager(INotificationMediatorFactory <TNotification> factory)
 {
     _mediator = factory.CreateMqMediator();
 }