Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DefaultControllerFactory vs IDependencyResolver

I have a little misunderstanding: when we implement IDependencyResolver it means that we can use DI for every part in the project. So even if i don't inherit from DefaultControllerFactory i can build controllers regestering dependencies?

edits: i recommend look through all these Brad Wilson's posts
also this post is useful

like image 593
Aleksei Chepovoi Avatar asked Dec 20 '12 07:12

Aleksei Chepovoi


1 Answers

Pedant note first. You cannot inherit from an interface (IDependencyResolver) but I assume you mean implement.

In short you have a choice between using either, you would not use both. So if you have the resolver set up you do not need to have a controller factory and vice versa.

I have only used DefaultControllerFactory in mvc with castle-windsor. You will need to be wary of one loose end in using IDependencyResolver if you are using castle-windsor also, there is no release method but there are probably ways around this.

With other frameworks such as ninject or unity IDependencyResolver is sometimes preferable.

like image 57
dove Avatar answered Sep 20 '22 10:09

dove