Convention over configuration
It is not difficult to register a few service types, one by one in a small application. But what about a production application with hundreds of services which should be wired to their implementations?
Convention-based configuration allows us to bind a group of services using a convention rather than defining individual bindings for each of them. For example, you can simply ask Ninject to bind all components to their base interfaces like this:
kernel.Bind(r => r .FromThisAssembly() .SelectAllClasses() .BindAllInterfaces());
In order to take advantage of the Convention based configuration, we should add refererence to the Ninject's Conventions extension. We can either use NuGet to install Ninject.Extensions.Conventions
or download the binary file from GitHub. We also need to add Ninject.Extensions.Conventions
to the using section of our code to make the previous syntax available.
As the syntax indicates, registering a convention-based binding at least consists...