"Program to an interface, not an implementation"which is quite accurate. However , I've lost at some point when i was designing my infrastructure layer. I came up with the idea of putting an abstraction over DI framework and designing top layers without them knowing which DI framework is used in application. Aim was in case i want to swap my DI framework , I could do it easily at Infrastucture layer by adding a concrete container implementation and activate it on runtime. One common container abstraction to rule them all!
At first it appeared quite logical to me , so I've made a researched on github if someone already done it and I've found ; LAN.Core.DependencyInjection .
This implementation was exactly what i was looking for except that they didnt implement container for Autofac which i am currently using in my project. I added source codes to my project and made Autofac implementation myself. Everthing was great, so abstract!
Well, not really. Problems occured as your needs in your project grow. Autofac is quite rich framework in terms of functionality and it was so wrong to restrict it to a common abstract container. I ended up adding those functions up to the abstract container.It slowly turned into Autofac container itself!
As a result, I just removed that abstraction because it was going to be an abstraction on another abstraction which is not really good. And i was recently reading Mark Seemanns blog and I have seen my faul design there , which is described as an anti-pattern : Conforming-Container
In summary ; do not put abstraction over your DI framework and make it more complicated. It will create more problems than it solves. Just use DI framework as itself!
Regards,