Chapter 13. Autofac
Menu
- Introducing Autofac
- Managing lifetime
- Working with multiple components
- Configuring difficult APIs
In the previous chapters, you saw how to map the principles and patterns from parts 1–3 to specific DI CONTAINERS. In this chapter, we’ll do the same with the Autofac DI CONTAINER.
Autofac is an example of what we could call second-generation DI CONTAINERS.
Note
The second-generation DI CONTAINERS are based directly on .NET 3.5, so their architectures are often directly based on the language and platform features that became available at that time. Not only do they have an intimate understanding of generics, but many also employ lambda expressions as central API elements. Although the majority of the mature DI CONTAINERS also support these more modern language constructs, their core engines are typically based on earlier .NET versions. Because the second-generation containers have no such baggage, they’re typically designed around these features from the ground up.
Autofac is a fairly comprehensive DI CONTAINER that offers a carefully designed and consistent API. It has been around since late 2007 and seems to have a fair-sized user base.[3]
3 No official statistics exist on DI CONTAINER usage, so this is my subjective assessment.