Translating Ninject to ASP.NET MVC 6 DI

前端 未结 2 895
情深已故
情深已故 2021-02-14 23:59

I am trying to get into the new ASP.NET MVC 6 stuff, but I\'m having a very hard time with their new DI system. I have tried to find resources online, but everything I find cove

2条回答
  •  灰色年华
    2021-02-15 00:30

    Also you could continue use Ninject by adding Microsoft.Framework.DependencyInjection.Ninject to your project and then configure it with following code:

    public IServiceProvider ConfigureServices(Microsoft.Framework.DependencyInjection.IServiceCollection services)
    {
        var kernel = CreateMyKernel();
        kernel.Populate(services); // Wire up configured services and Ninject kernel with Microsoft tool
        return kernel.Get();
    }
    

提交回复
热议问题