Search code examples
c#inversion-of-controlninjectchain-of-responsibility

How do I declare a chain of responsibility using decorators in Ninject?


I'd like to declare a chain of responsibility using decorators in Ninject.

Has anyone done that before?

Thanks.


Solution

  • In the new ninject 2.0 syntax you can accomplish this by the following newer syntax:

    Bind<IEmailSender>().To<LoggingEmailSender>();
    Bind<IEmailSender>().To<SmtpClientEmailSender>().WhenInjectedInto<LoggingEmailSender>();
    

    Just ran into this myself and found that was the way to do it as ForMembersOf has been removed in ninject 2.0