转到 `` 的内部,发现有如下代码:
// ... public async Task TriggerEventsAsync(EntityChangeReport changeReport) { // 触发领域事件。 await TriggerEventsInternalAsync(changeReport).ConfigureAwait(false); if (changeReport.IsEmpty() || UnitOfWorkManager.Current == null) { return; } await UnitOfWorkManager.Current.SaveChangesAsync().ConfigureAwait(false); } protected virtual async Task TriggerEventsInternalAsync(EntityChangeReport changeReport) { // 触发默认的实体变更事件,例如某个实体被创建、修改、删除。 await TriggerEntityChangeEvents(changeReport.ChangedEntities).ConfigureAwait(false); // 触发用户自己发送的领域事件。 await TriggerLocalEvents(changeReport.DomainEvents).ConfigureAwait(false); await TriggerDistributedEvents(changeReport.DistributedEvents).ConfigureAwait(false); } // ... protected virtual async Task TriggerLocalEvents(List<DomainEventEntry> localEvents) { foreach (var localEvent in localEvents) { await LocalEventBus.PublishAsync(localEvent.EventData.GetType(), localEvent.EventData).ConfigureAwait(false); } } protected virtual async Task TriggerDistributedEvents(List<DomainEventEntry> distributedEvents) { foreach (var distributedEvent in distributedEvents) { await DistributedEventBus.PublishAsync(distributedEvent.EventData.GetType(), distributedEvent.EventData).ConfigureAwait(false); } } 三、系列文章目录点击我 跳转到文章总目录。