How can I get started with ASP.NET (5) Core and Castle Windsor for Dependency Injection?

后端 未结 3 1319
滥情空心
滥情空心 2021-02-05 12:34

Background:

I\'ve used Castle Windsor with Installers and Facilities according to the Castle Windsor tutorial with earlier versions of MVC (pre-6) and WebAPI.

3条回答
  •  旧巷少年郎
    2021-02-05 13:08

    So looking at your code, literally all of it can be replaced by Castle.Windsor.MsDependencyInjection library.

    Add Castle.Windsor.MsDependencyInjection to your project then use like so:

        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
    
            // Normal component registration can go here...
    
            return WindsorRegistrationHelper.CreateServiceProvider(yourWindsorContainer, services);
        }
    

提交回复
热议问题