public IntegrationEventLogService(
            AWContext dbContext,
            Assembly eventTypesAssembly
            )
        {
            this.dbContext = dbContext;

            eventTypes = eventTypesAssembly
                         .GetTypes()
                         .Where(t => t.Name.EndsWith(nameof(IntegrationEvent)))
                         .ToList();
        }
        public static async Task DispatchDomainEventsAsync(this IMediator mediator, AWContext ctx)
        {
            var domainEntities = ctx.ChangeTracker
                                 .Entries <Entity>()
                                 .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any());

            var domainEvents = domainEntities
                               .SelectMany(x => x.Entity.DomainEvents)
                               .ToList();

            domainEntities.ToList()
            .ForEach(entity => entity.Entity.ClearDomainEvents());

            foreach (var domainEvent in domainEvents)
            {
                await mediator.Publish(domainEvent);
            }
        }
Esempio n. 3
0
 public EfRepository(AWContext dbContext) : base(dbContext)
 {
     this.dbContext = dbContext;
 }