0

I understand how to configure the decorates as explained here. But I see one problem. In my case, I want avoid the dependency of the Repository.

Bind<IRepository>().To<Repository>().WhenInjectedInto<CachedRopsitory>();
Bind<IRepository>().To<CachedRepository>().WhenInjectedInto<CachedLoggedRepository>();
Bind<IRepository>().To<CachedLoggedRepository>();

To elaborate, I have UI, BL(Business Layer), DL(Data Layer). UI and DL reference BL. The above code sits in composition root in UI. And IRepository sits in BL and Repository belongs to Data layer. I dont want to reference DL in UI. That is I dont want to make DL a dependency to UI. so the code we use in such scenario is as follows using Convention over configuration.

m_Kernel.Bind(x => x.FromAssembliesMatching("Northwind.*.dll").SelectAllClasses().
    BindAllInterfaces());

So the question is simple, how can I use conditional bindings with convention over configuration?

Community
  • 1
  • 1
VivekDev
  • 20,868
  • 27
  • 132
  • 202

0 Answers0