Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to register dependencies by convention in .NET Core?

Some containers allow for registration by name. Ninject is one as an example.

Does the .NET Core DI container support this? And if not, are there plans or third party libraries to support this?

like image 566
drizzie Avatar asked Aug 19 '17 23:08

drizzie


1 Answers

Does the .NET Core DI container support this? And if not, are there plans or third party libraries to support this?

Short Answer: NO and NO

Source: Introduction to Dependency Injection in ASP.NET Core

Replacing the default services container

The built-in services container is meant to serve the basic needs of the framework and most consumer applications built on it. However, developers can replace the built-in container with their preferred container. The ConfigureServices method typically returns void, but if its signature is changed to return IServiceProvider, a different container can be configured and returned. There are many IOC containers available for .NET.

(Emphasis mine)

With that you can check if Ninject has an extension for .net core and see if you can integrate it.

like image 90
Nkosi Avatar answered Nov 15 '22 10:11

Nkosi