I need to pass an Interface as a parameter in another service's constructor.
MSAuthService constructor needs 3 parameters:
public MSAuthService(string jwtSecret, int jwtLifespan, IUserService userService)
{
this._jwtSecret = jwtSecret;
this._jwtLifespan = jwtLifespan;
this._userService = userService;
}
Startup.cs:
services.AddScoped<IUserService, UserManager>();
....
services.AddSingleton<IAuthService>(
new MSAuthService(
MyConfigurationManager.GetJWTSecretKey(),
MyConfigurationManager.GetJWTLifespan(),
// I want to pass IUserService as parameter here
)
);
I couldn't figure out how to pass the IUserService to MSAuthService's constructor. I don't want to pass UserManager (concrete) class as a parameter.