From the course: Advanced ASP.NET Web API 2.2
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Scope of a dependency
- [Instructor] Controllers are created per request. To manage the object lifetimes, the IdependencyResolver uses the concept of a scope. But by using the Unity container, we can take control of the lifetime of the objects of all dependencies. Because Unity container includes different lifetime managers for different purposes. So we have the transient lifetime manager, which creates a new object every time, that we call the resolve, or resolve all method. Container Controlled lifetime manager creates a singleton object the first time that we call these methods. And we have hierarchical lifetime manager, which is the same like the Container Controlled lifetime manager, but by using this lifetime manager, the child container can create its own singleton object. Another one is the PerResolve lifetime manager, which is similar to the transient lifetime manager, but it reuses the same object of the registered type. Another one is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.