SHARE
TWEET

Configuração de injeção de dependencia

sangueroots May 11th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using ProverOperacoesWF.Common.CQRS.Command;
  2. using ProverOperacoesWF.Common.CQRS.Query;
  3. using ProverOperacoesWF.Common.ServiceBus;
  4. using ProverOperacoesWF.Common.ServiceBus.Command;
  5. using ProverOperacoesWF.Common.ServiceBus.Query;
  6. using ProverOperacoesWF.Core.Commands.Base;
  7. using ProverOperacoesWF.Data.Context;
  8. using ProverOperacoesWF.Data.Models;
  9. using ProverOperacoesWF.SharedKernel.Containers;
  10. using SimpleInjector;
  11.  
  12. namespace ProverOperacoesWF.IoC
  13. {
  14.     public static class ContainerFactory
  15.     {
  16.         public static Container GetContainer(ScopedLifestyle scopedLifestyle)
  17.         {
  18.             var container = new Container();
  19.             container.Options.DefaultScopedLifestyle = scopedLifestyle;
  20.  
  21.             container.Register<IDataContext, ApplicationDbContext>(Lifestyle.Scoped);
  22.             container.Register<ICommandBus, CommandBus>(Lifestyle.Scoped);
  23.             container.Register<IQueryBus, QueryBus>(Lifestyle.Scoped);
  24.  
  25.             var coreLayerAssemblies = new[] { typeof(CommandBase).Assembly };
  26.             container.Register(typeof(ICommandHandler<,>), coreLayerAssemblies);
  27.             container.Register(typeof(IQueryHandler<,>), coreLayerAssemblies);
  28.             //container.Register(typeof(IEventHandler<>), coreLayerAssemblies);
  29.             //container.Register(typeof(IValidator<>), coreLayerAssemblies);
  30.  
  31.             ApplicationContainer.SetApplicationContainer(container);
  32.  
  33.             return container;
  34.         }
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top