I left Ninject… Poor guy… Ninject was my favorite dependency container injector, but there is a new hype. The new hype is called ‘Autofac’.
The main reason for the switch was the support of UWP (Universal Windows Platform) and .Net Core. Ninject is still in Beta while Autofac is used also by Microsoft themselves.
So, time to do a switch. The following caveats were found:
Instead of doing a bind to something, you register something as an interface/method.
By default, Autofac does not support the creation of an unregistered, concrete class like Ninject does.
Here, you need to add the following line:
I need the creation of unregistered class, because the DatenMeister uses a plugin-like architecture where the plugins are created by the dependency injection.
In a future version, this class will be replaced by a more specific registration
Autofac differs between the builder, the container and the lifetime scope. In Ninject, this was more or less voluntary. This leads to some architectural changes, since some of the methods used the global builder which is not available after everything has been built. Not nice, but acceptable.
After having built the container, the builder cannot be changed anymore. A new builder has to be created. This also leads to some architectural changes.
In the end… a lot of refactoring without improving the product…