开发者

Autofac vs Ninject contextual binding?

开发者 https://www.devze.com 2023-02-07 05:42 出处:网络
1) Autofac and Ninject, which one is better in cont开发者_开发知识库extual binding? 2) With Ninject, I can bind to types in a specific namespace:

1) Autofac and Ninject, which one is better in cont开发者_开发知识库extual 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?

Thanks!

(sorry for my English)


Of the two, only Ninject provides this functionality.

It is a useful feature but Autofac excludes it to prevent fragility in other Autofac-specific features that rely on the dependency being unaware of the dependent component.

If you have a scenario that would benefit from this kind of behaviour in Autofac, feel free to post it and I'll have a shot at translating it into Autofac's way of doing things :)

Hope this helps, Nick

0

精彩评论

暂无评论...
验证码 换一张
取 消