Autofac vs Ninject context binding?

1) Autofac and Ninject, which one is better in the context of binding?

2) With Ninject, I can bind to types in a specific namespace:

Bind<A>().To<B>().When(context => 
    context.ParentContext.Binding.Service.Namespace == "MyProject.Common");

Can I do this with Autofac?

Thank!

(sorry for my English)

+1
source share
1 answer

Of the two, only Ninject provides this functionality.

This is a useful feature, but Autofac excludes it to prevent the fragility of other Autofac-dependent functions that rely on a dependency that does not know the dependent component.

If you have a script that would benefit from this behavior in Autofac, feel free to post it, and I will take a picture when you translate it into Autofac a way to do things :)

Hope this helps Nick

+2
source

Source: https://habr.com/ru/post/1788874/


All Articles