Now we will use a DI container called DryIoc to be the external component to resolve our dependencies.
In this recipe, we'll use another DI container-DryIoc. DryIoc is very well received by the community.
DryIoc is also very light, but it has almost every feature that you would expect from a complete DI container library.
We want to compose the application's object graph.
To do that, we will create a ConfigureService
method that returns an IServiceProvider
type.
As in the first recipe, we will do the following:
- Inject the
ServiceProducts
class by using a constructor in theHomeController
of an ASP.NET MVC 6 application. - Create a class called
Product
. - Create an interface called
IProductService.
- Create a class called
ProductService
. - Modify
HomeController
to add a constructor that will injectIProductService.
- Create an action method called
Products
inHomeController
. - Create a view called
Products.cshtml
. - Now, to use DryIoc, we will add the
DryIoc
and...