Beispiel #1
0
        private static void ConfigureCompositionRoot(string connectionString, ILogger logger, IEmailSender emailSender)
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterModule(new DataAccessModule(connectionString));
            containerBuilder.RegisterModule(new LoggingModule(logger));
            containerBuilder.RegisterModule(new EmailsModule(emailSender));
            containerBuilder.RegisterModule(new MediatrModule());
            containerBuilder.RegisterModule(new ProcessingModule());
            containerBuilder.RegisterModule(new DomainModule());
            containerBuilder.RegisterModule(new ApplicationModule());

            var container = containerBuilder.Build();

            CustomersCompositionRoot.SetContainer(container);
        }
Beispiel #2
0
 public static async Task Execute(ICommand command)
 {
     await using var scope = CustomersCompositionRoot.BeginLifetimeScope();
     var mediator = scope.Resolve <IMediator>();
     await mediator.Send(command);
 }