The default Wep Application in VS 2013 with "Individual User Accounts" comes with an account controller with the following code :
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
{
UserManager = userManager;
SignInManager = signInManager;
}
private ApplicationUserManager _userManager;
public ApplicationUserManager UserManager
{
get
{
return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
private set
{
_userManager = value;
}
}
and this line in Startup.Auth.cs
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
I'd like to understand what mechanism passes userManager parameter to the constructor. I believe dependendy injection pattern is used here. If I'm correct, where in the Visual Studio solution can I find the code responsible for dependency injection ?
Next for the UserManager part, why should we test if _userManager is null if it's been set up in the controller ?