If you are using Ninject, you may find yourself duplicating a lot of code for binding interfaces to their respective classes.
Fortunately, Ninject has a NuGet package which can take a lot of that tedious work away and bind interfaces to classes automatically!
The name of the Ninject package is called Ninject.Extensions.Conventions:
Once you have installed the NuGet package, you can add the following code to the RegisterServices method of your NinjectWebCommon.cs file:
That is all that is needed to get your Ninject project up and running!
Fortunately, Ninject has a NuGet package which can take a lot of that tedious work away and bind interfaces to classes automatically!
The name of the Ninject package is called Ninject.Extensions.Conventions:
Once you have installed the NuGet package, you can add the following code to the RegisterServices method of your NinjectWebCommon.cs file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Use Ninject Extensions Conventions | |
kernel.Bind( | |
b => b.FromThisAssembly() | |
.SelectAllClasses() | |
.BindAllInterfaces()); |
No comments:
Post a Comment