I'm coming to build new "Enterprise solution"开发者_C百科
So i decided to use "Onion Architecture" because i wanna as much as flexible architecture.
But I'm new to "Dependency Resolution" concern.
As I understand I should put Factories "Implementations" in this Layer and this layer has references to all other layers.
Then I wanna know how to make new instance of IFactory in the "UI Layer" when the FactoryImplementation in DependencyResolution Layer and UI Layer don't have reference to "DependencyResolution Layer"
Edit::
Thanks to Mr. Erik
But after I saw many of these links I still have problem when i want to "Register" Implementations to their "Interfaces" because I can't do something like this in UI Project:
kernel.Bind<ITaxCalculator>()
.To<TaxCalculator>()
.WithConstructorArgument("rate", .2M);
Because UI Project can't access TaxCalculator
"Implementation".
I think the best solution would be to use a Dependency Container (aka IOC container) to resolve your references, such as Castle Windsor or Unity if you're on .NET. They make you able to configure up the dependency resolution without references to the actual implementations in the UI layer.
EDIT: Some links:
- http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx
- http://www.castleproject.org/index.html
- Why do I need an IoC container as opposed to straightforward DI code?
- http://martinfowler.com/articles/injection.html
- http://manning.com/seemann/
- http://www.theserverside.com/news/1321158/A-beginners-guide-to-Dependency-Injection
精彩评论