-
Book Overview & Buying
-
Table Of Contents
Mastering Ninject for Dependency Injection
By :
As our application grows, the list of service registrations gets longer, and it would be difficult to manage this list. Ninject modules are a good way to segregate our type bindings into distinct groups of bindings, which can be easily organized into separate files. Minimum requirement for a class to be accepted as a Ninject module is to implement the INinjectModule interface. Implementing this interface requires us to implement three methods and two properties each time we need to create a module. It is a good idea to implement this interface as an abstract class once, and extend it whenever we need to create a Ninject module. The good news is that Ninject has already implemented this abstract class, which is named NinjectModule.
Here is how to register our MailService classes in a module:
class MailServiceModule: NinjectModule
{
public override void Load()
{
Bind<ILogger>().To<ConsoleLogger>().InSingletonScope();
Bind<MailServerConfig>().ToSelf...
Change the font size
Change margin width
Change background colour