To solve your problem you just need to wire IUserManager
in DI, and make sure UserProfile
dependency is resolved.
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddSingleton<IUserManager, UserManager>();
services.AddSingleton(provider => new MapperConfiguration(cfg =>
{
cfg.AddProfile(new UserProfile(provider.GetService<IUserManager>()));
}).CreateMapper());
}
And having that said, I would probably try to keep single responsibility per class, and not have any services injected into mapping profiles. You can populate your objects just before the mapping instead. This way it might be easier to unit test as well.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…