Part 4. DI Containers

 

The previous parts of the book have been about the various principles and patterns that together define DI. As chapter 3 explained, a DI Container is an optional tool that you can use to implement a lot of the general-purpose infrastructure that you would otherwise have to implement if you were using Pure DI.

Throughout the book, we’ve kept the discussion container agnostic, which means we’ve only taught you Pure DI. Don’t interpret this as a recommendation of Pure DI per se; rather, we want you to see DI in its purest form, untainted by any particular container’s API.

Many excellent DI Containers are available for the .NET platform. In chapter 12, we’ll discuss when you should use one of these containers and when you should stick with Pure DI. The remaining chapters in part 4 cover a selection of three free and open source DI Containers. In each chapter, we provide detailed coverage of that particular container’s API as it relates to the dimensions covered in part 3, as well as various other issues that traditionally cause beginners grief. The containers covered are Autofac (chapter 13), Simple Injector (chapter 14), and Microsoft.Extensions.DependencyInjection (chapter 15).