예제 #1
0
        public IEntityEventPublisher Create(IServiceProvider provider)
        {
            var context      = provider.GetRequiredService <TContext>();
            var messageQueue = provider.GetRequiredService <IMessageQueue>();
            var uow          = new EfUnitOfWork(context);

            return(new EntityEventPublisher(
                       messageQueue,
                       uow.CreateRepository <EntityEventLog, Guid>(),
                       provider.GetService <ILogger <EntityEventPublisher> >()));
        }
예제 #2
0
 public static IServiceCollection AddDbContextEventPublisher <TContext>(this IServiceCollection services)
     where TContext : DbContext, IEntityEventLogContext
 {
     services.AddScoped <IEntityEventPublisher>(provider =>
     {
         var context      = provider.GetRequiredService <TContext>();
         var messageQueue = provider.GetRequiredService <IMessageQueue>();
         var uow          = new EfUnitOfWork(context);
         return(new EntityEventPublisher(
                    messageQueue,
                    uow.CreateRepository <EntityEventLog, Guid>(),
                    provider.GetService <ILogger <EntityEventPublisher> >()));
     });
     return(services);
 }