Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DomainRepositoryBase{TAggregate}"/> class.
        /// </summary>
        /// <param name="domainEventBroker">A broker used for publishing domain events generated by aggregate roots.</param>
        protected DomainRepositoryBase(DomainEventBrokerBase domainEventBroker)
        {
            if (domainEventBroker == null)
            {
                throw new ArgumentNullException("domainEventBroker");
            }

            this.domainEventBroker = domainEventBroker;
        }
Пример #2
0
        /// <summary>
        /// Executes all events that have been applied to the given aggregate root instance.
        /// </summary>
        /// <param name="aggregateRoot">The changed aggregate root instance.</param>
        /// <param name="eventBroker">The event broker to be used for publishing events.</param>
        protected static void ExecuteAppliedEvents(TAggregate aggregateRoot, DomainEventBrokerBase eventBroker)
        {
            if (aggregateRoot == null)
            {
                throw new ArgumentNullException("aggregateRoot");
            }

            eventBroker.PublishEvents(aggregateRoot.GetAppliedEvents());
        }
Пример #3
0
        /// <summary>
        /// Asynchronously executes all events that have been applied to the given aggregate root instance.
        /// </summary>
        /// <param name="aggregateRoot">The changed aggregate root instance.</param>
        /// <param name="eventBroker">The event broker to be used for publishing events.</param>
        protected static async Task ExecuteAppliedEventsAsync(TAggregate aggregateRoot, DomainEventBrokerBase eventBroker)
        {
            if (aggregateRoot == null)
            {
                throw new ArgumentNullException("aggregateRoot");
            }

            await eventBroker.PublishEventsAsync(aggregateRoot.GetAppliedEvents()).ConfigureAwait(false);
        }