Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
how does .net core implement dependency injection for different lifetimes?
how does a instance created and disposed for different lifetimes?

What I have tried:

What i could think is
1.singleton - use a global static dictionary to keep all the instance
2.scope - no idea.
3.transient - new instance() for every request.

how does .net core(or any other IoC library) do in the dependency injection engine?
Posted
Updated 23-Apr-20 21:40pm
Comments
Tomas Takac 24-Apr-20 2:36am    
You can have a look at the source code of a IoC container and find out for yourself. Here are the sources for Unity container[^] for example.

There are a series of articles here on CodeProject that answer this question. The first part can be found here: Dependency Inversion Principle, IoC Container, and Dependency Injection: Part 1[^] Most IoC containers provide similar implementations.
 
Share this answer
 
Comments
Maciej Los 24-Apr-20 3:38am    
5ed!
 
Share this answer
 
v2
Comments
Pete O'Hanlon 24-Apr-20 6:38am    
5ed
Maciej Los 24-Apr-20 6:40am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900