コード例 #1
0
        // 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);
        }
コード例 #2
0
        // 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);
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: mgce/stocqres
        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));
        }