Ninject dependency injection with Decorator pattern

前端 未结 1 981
梦谈多话
梦谈多话 2021-01-01 09:43

Say, I have such classes hierarchy:

public interface IRepository { }

public class SomeSimpleRepository : IRepository {}

Now I want to \"de

相关标签:
1条回答
  • 2021-01-01 10:17

    Use WhenInjectedInto:

    Bind<IRepository>().To<MoreAdvancedRespository>
                       .WhenInjectedInto<TrickyRepository>();
    Bind<IRepository>().To<SomeSimpleRepository>
                       .WhenInjectedInto<MoreAdvancedRespository>();
    

    See this blog post for more info.

    0 讨论(0)
提交回复
热议问题