We will now create a helper class that will ease the process of resolving object graphs through Autofac. This will help us to create types based on a configured IoC container. In this project, we will use Autofac as the IoC library by going through the following steps:
- In the HotDogOrNot project, install the Autofac NuGet package to the HotDogOrNot project.
- Create a new class called Resolver in the root.
- Add a private static field of the IContainer type called container (from Autofac).
- Add a public static method called Initialize with IContainer as a parameter. Set the value of the parameter to the container field.
- Add a generic public static method called Resolve, which will return an instance that is based on the type argument with the Resolve method of IContainer, as shown in the following code block:
using System;
using Autofac...