I have read this official documentation: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection.
There is something i do not understand in constructor injection:
Let's have a look to my code, which works fine:
public class HomeController : Controller
{
private readonly UserManager<Utilisateurs> _userManager;
private readonly SignInManager<Utilisateurs> _signInManager;
private readonly RoleManager<IdentityRole> _roleManager;
public HomeController(
SignInManager<Utilisateurs> signInManager,
UserManager<Utilisateurs> userManager,
RoleManager<IdentityRole> roleManager)
{
_userManager = userManager;
_signInManager = signInManager;
_roleManager = roleManager;
}
It works fine too if change constructor parameter orders or if i remove some parameters like this:
public class HomeController : Controller
{
private readonly UserManager<Utilisateurs> _userManager;
private readonly SignInManager<Utilisateurs> _signInManager;
public HomeController(
UserManager<Utilisateurs> userManager
SignInManager<Utilisateurs> signInManager,
)
{
_userManager = userManager;
_signInManager = signInManager;
}
I have understood the concept of DI. What i do not understand is how does it works in C# to have something dynamic in constructor parameters ? Is there a set of all kind of overload constructors ?
Thanks