How the binding are done with decorators using Ninject?

后端 未结 1 1159
感动是毒
感动是毒 2020-12-03 12:00

Based on this question : Should thoses kind of service go injected in a base class ? (versus static classes).

How the binding would be done with decorators using Nin

相关标签:
1条回答
  • 2020-12-03 12:53

    You have to use conditional bindings e.g

    Bind<IRepository>().To<Repository>().WhenInjectedInto<CachedRopsitory>();
    Bind<IRepository>().To<CachedRepository>().WhenInjectedInto<CachedLoggedRepository>();
    Bind<IRepository>().To<CachedLoggedRepository>();
    
    0 讨论(0)
提交回复
热议问题