Exemple #1
0
        private void InitializeContainer(IApplicationBuilder app)
        {
            //add application presentation components
            container.RegisterMvcControllers(app);
            container.RegisterMvcViewComponents(app);

            //add application services. For instance
            //================================================APPLICATION========================================================
            container.Register(typeof(InterfaceAppServiceBase <>), typeof(AppServiceBase <>).Assembly, Lifestyle.Scoped);
            container.Register <InterfaceCategoriaAppService, CategoriaAppService>(Lifestyle.Scoped);
            container.Register <InterfaceClienteAppService, ClienteAppService>(Lifestyle.Scoped);
            container.Register <InterfaceProdutoAppService, ProdutoAppService>(Lifestyle.Scoped);
            container.Register <InterfaceImpostoAppService, ImpostoAppService>(Lifestyle.Scoped);

            //================================================DOMAIN============================================================
            container.Register(typeof(InterfaceServiceBase <>), typeof(ServiceBase <>).Assembly, Lifestyle.Scoped);
            container.Register <InterfaceCategoriaService, CategoriaService>(Lifestyle.Scoped);
            container.Register <InterfaceClienteService, ClienteService>(Lifestyle.Scoped);
            container.Register <InterfaceProdutoService, ProdutoService>(Lifestyle.Scoped);
            container.Register <InterfaceImpostoService, ImpostoService>(Lifestyle.Scoped);

            //===============================================INFRASTRUCTURE=====================================================
            container.Register(typeof(InterfaceRepositoryBase <>), typeof(RepositoryBase <>).Assembly, Lifestyle.Scoped);
            container.Register <InterfaceCategoriaRepository, CategoriaRepository>(Lifestyle.Scoped);
            container.Register <InterfaceClienteRepository, ClienteRepository>(Lifestyle.Scoped);
            container.Register <InterfaceProdutoRepository, ProdutoRepository>(Lifestyle.Scoped);
            container.Register <InterfaceImpostoRepository, ImpostoRepository>(Lifestyle.Scoped);

            //allow Simple Injector to resolve services from ASP.NET Core
            container.AutoCrossWireAspNetComponents(app);
        }
Exemple #2
0
        public static void AutoCrossWireAspNetComponents(this Container container, IApplicationBuilder app)
        {
            Requires.IsNotNull(app, nameof(app));
            Requires.IsNotNull(container, nameof(container));

            container.AutoCrossWireAspNetComponents(app.GetApplicationServices());
        }
Exemple #3
0
        public virtual void Bootstrap(IServiceProvider serviceProvider)
        {
            ConfigureContainerWithServicesAction = () => ConfigureContainer(serviceProvider, _container);

            Host = new HostBuilder()
                   .ConfigureServices(sc => ConfigureServicesAndAppContainer(serviceProvider, sc))
                   .Build();

            _container.AutoCrossWireAspNetComponents(Host.Services);
            _container.Verify();
        }
Exemple #4
0
        private void InitializeContainer(IApplicationBuilder app)
        {
            // Add application presentation components:
            _container.RegisterMvcControllers(app);
            _container.RegisterMvcViewComponents(app);

            // Add application services. For instance:
            //_container.Register<IUserService, UserService>(Lifestyle.Scoped);

            // Allow Simple Injector to resolve services from ASP.NET Core.
            _container.AutoCrossWireAspNetComponents(app);
        }
Exemple #5
0
        private void InitializeContainer(IApplicationBuilder app)
        {
            //add application presentation components
            container.RegisterMvcControllers(app);
            container.RegisterMvcViewComponents(app);

            #region Application
            //add application services. For instance
            //====================================================APPLICATION========================================================
            container.Register(typeof(IAppServiceBase <>), typeof(AppServiceBase <>).Assembly, Lifestyle.Scoped);
            //===============================Pessoa=================================================
            container.Register <IPessoaAppService, PessoaAppService>(Lifestyle.Scoped);
            container.Register <IPessoaTipoAppService, PessoaTipoAppService>(Lifestyle.Scoped);
            //==============================Tipos===================================================
            container.Register <IFisicaAppService, FisicaAppService>(Lifestyle.Scoped);
            container.Register <IJuridicaAppService, JuridicaAppService>(Lifestyle.Scoped);
            //==============================Clientes================================================
            container.Register <IClienteAppService, ClienteAppService>(Lifestyle.Scoped);

            //==============================Contatos================================================
            container.Register <IContatoAppService, ContatoAppService>(Lifestyle.Scoped);

            //===============================CONTATOS/EMAILS========================================
            //=============================Emails===================================================
            container.Register <IEmailAppService, EmailAppService>(Lifestyle.Scoped);
            //==============================Endereços===============================================
            container.Register <IEnderecoAppService, EnderecoAppService>(Lifestyle.Scoped);
            container.Register <IEnderecoClienteAppService, EnderecoClienteAppService>(Lifestyle.Scoped);
            container.Register <IEnderecoPessoaAppService, EnderecoPessoaAppService>(Lifestyle.Scoped);
            //=============================Telefones================================================
            container.Register <ITelefoneAppService, TelefoneAppService>(Lifestyle.Scoped);
            container.Register <ITelefoneTipoAppService, TelefoneTipoAppService>(Lifestyle.Scoped);

            //============================Compras===================================================
            //============================ControleEstoque===========================================
            container.Register <IEstoqueAppService, EstoqueAppService>(Lifestyle.Scoped);
            //============================Produção==================================================
            container.Register <ICategoriaAppService, CategoriaAppService>(Lifestyle.Scoped);
            container.Register <IProdutoAppService, ProdutoAppService>(Lifestyle.Scoped);
            //============================Vendas====================================================
            container.Register <IDetalhePedidoAppService, DetalhePedidoAppService>(Lifestyle.Scoped);
            container.Register <IDetalheVendaAppService, DetalheVendaAppService>(Lifestyle.Scoped);
            container.Register <IImpostoAppService, ImpostoAppService>(Lifestyle.Scoped);
            container.Register <IPedidoAppService, PedidoAppService>(Lifestyle.Scoped);
            container.Register <IVendaAppService, VendaAppService>(Lifestyle.Scoped);

            #endregion

            #region Domain
            //================================================DOMAIN===================================================================
            container.Register(typeof(IServiceBase <>), typeof(ServiceBase <>).Assembly, Lifestyle.Scoped);

            //==========================Pessoas==========================================================
            container.Register <IPessoaService, PessoaService>(Lifestyle.Scoped);
            container.Register <IPessoaTipoService, PessoaTipoService>(Lifestyle.Scoped);
            //==========================Tipos============================================================
            container.Register <IFisicaService, FisicaService>(Lifestyle.Scoped);
            container.Register <IJuridicaService, JuridicaService>(Lifestyle.Scoped);
            //==========================Clientes=========================================================
            container.Register <IClienteService, ClienteService>(Lifestyle.Scoped);

            //=========================Contatos==========================================================
            container.Register <IContatoService, ContatoService>(Lifestyle.Scoped);

            //============================CONTATOS/EMAILS================================================
            //==========================Emails===========================================================
            container.Register <IEmailService, EmailService>(Lifestyle.Scoped);
            //==========================Endereços========================================================
            container.Register <IEnderecoService, EnderecoService>(Lifestyle.Scoped);
            container.Register <IEnderecoPessoaService, EnderecoPessoaService>(Lifestyle.Scoped);
            container.Register <IEnderecoClienteService, EnderecoClienteService>(Lifestyle.Scoped);
            //==========================Telefone=========================================================
            container.Register <ITelefoneService, TelefoneService>(Lifestyle.Scoped);
            container.Register <ITelefoneTipoService, TelefoneTipoService>(Lifestyle.Scoped);

            //==========================Compras==========================================================

            //==========================ControleEstoque==================================================
            container.Register <IEstoqueService, EstoqueService>(Lifestyle.Scoped);
            //==========================Produção=========================================================
            container.Register <ICategoriaService, CategoriaService>(Lifestyle.Scoped);
            container.Register <IProdutoService, ProdutoService>(Lifestyle.Scoped);

            //==========================Vendas===========================================================
            container.Register <IDetalhePedidoService, DetalhePedidoService>(Lifestyle.Scoped);
            container.Register <IDetalheVendaService, DetalheVendaService>(Lifestyle.Scoped);
            container.Register <IImpostoService, ImpostoService>(Lifestyle.Scoped);
            container.Register <IPedidoService, PedidoService>(Lifestyle.Scoped);
            container.Register <IVendaService, VendaService>(Lifestyle.Scoped);

            #endregion

            #region Infrastructure
            //===============================================INFRASTRUCTURE==============================================================
            container.Register(typeof(IRepositoryBase <>), typeof(RepositoryBase <>).Assembly, Lifestyle.Scoped);
            //==========================Pessoas==========================================================
            container.Register <IPessoaRepository, PessoaRepository>(Lifestyle.Scoped);
            container.Register <IPessoaTipoRepository, PessoaTipoRepository>(Lifestyle.Scoped);
            //==========================Tipos============================================================
            container.Register <IJuridicaRepository, JuridicaRepository>(Lifestyle.Scoped);
            container.Register <IFisicaRepository, FisicaRepository>(Lifestyle.Scoped);
            //==========================Clientes=========================================================
            container.Register <IClienteRepository, ClienteRepository>(Lifestyle.Scoped);

            //==========================Contatos=========================================================
            container.Register <IContatoRepository, ContatoRepository>(Lifestyle.Scoped);

            //=============================CONTATOS/EMAILS===============================================
            //==========================Emails===========================================================
            container.Register <IEmailRepository, EmailRepository>(Lifestyle.Scoped);
            //==========================Endereços========================================================
            container.Register <IEnderecoRepository, EnderecoRepository>(Lifestyle.Scoped);
            container.Register <IEnderecoClienteRepository, EnderecoClienteRepository>(Lifestyle.Scoped);
            container.Register <IEnderecoPessoaRepository, EnderecoPessoaRepository>(Lifestyle.Scoped);
            //==========================Telefone=========================================================
            container.Register <ITelefoneRepository, TelefoneRepository>(Lifestyle.Scoped);
            container.Register <ITelefoneTipoRepository, TelefoneTipoRepository>(Lifestyle.Scoped);
            //==========================Compras==========================================================
            //==========================ControleEstoque==================================================
            container.Register <IEstoqueRepository, EstoqueRepository>(Lifestyle.Scoped);
            //==========================Produção=========================================================
            container.Register <ICategoriaRepository, CategoriaRepository>(Lifestyle.Scoped);
            container.Register <IProdutoRepository, ProdutoRepository>(Lifestyle.Scoped);
            //==========================Vendas===========================================================
            container.Register <IDetalhePedidoRepository, DetalhePedidoRepository>(Lifestyle.Scoped);
            container.Register <IDetalheVendaRepository, DetalheVendaRepository>(Lifestyle.Scoped);
            container.Register <IImpostoRepository, ImpostoRepository>(Lifestyle.Scoped);
            container.Register <IPedidoRepository, PedidoRepository>(Lifestyle.Scoped);
            container.Register <IVendaRepository, VendaRepository>(Lifestyle.Scoped);

            #endregion
            //allow Simple Injector to resolve services from ASP.NET Core
            container.AutoCrossWireAspNetComponents(app);
        }