Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
The question is not very clear.
If about how DI understands which implementation to use - everything is simple, you yourself specify it for a specific interface.
And if you are interested in how DI understands what to pass to a constructor: through reflection, Type has a GetConstructors() method - get a list of ConstructorInfo describing each of the declared constructors. Next, you can get a list of parameters ( ParameterInfo ) via GetParameters() and find one whose parameter types are all known to DI, instantiate them and then instantiate the requested class, such as a controller, using, for example, Activator.CreateInstancewhere the type of the class we need and the list of arguments are passed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question