// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); // app Settings config services.Configure <AppSettings>(Configuration.GetSection("Apis")); // Infra InfrastructureDependencyContainer.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); // app Settings config services.Configure <AppSettings>(Configuration.GetSection("Apis")); // Services services.AddTransient <IEmployeeService, EmployeeService>(); services.AddTransient <IEmployeeRepository, EmployeeRepository>(); services.AddAutoMapper(); // Infra InfrastructureDependencyContainer.RegisterServices(services); }
private IServiceProvider AddAutofac(IServiceCollection services) { var builder = new ContainerBuilder(); CoreDependencyContainer.Load(builder); InfrastructureDependencyContainer.Load(builder); IdentityDependencyContainer.Load(builder); CustomerDependencyContainer.Load(builder); SharedKernelDependencyResolver.Load(builder); CustomersApiContainer.Load(builder); TransactionsDependencyResolver.Load(builder); var assemblies = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypesSafely()).Where(a => a.Namespace != null && a.Namespace.Contains("Stocqres")).ToArray(); builder.ConfigureCqrs(assemblies); builder.RegisterGenericDecorator(typeof(TransactionalCommandHandlerDecorator <>), typeof(ICommandHandler <>), "commandHandler"); builder.Populate(services); builder.ConfigureMongo(); RegisterRepositories(builder); ApplicationContainer = builder.Build(); return(new AutofacServiceProvider(ApplicationContainer)); }