I'm working on an WebApi project, where I'm using Automapper to map certain Dto's to Entities. So far i needed only one dependency injected for manually mapping a certain property. Now I want to inhject another dependency. My constructor in the AutoMapper class looks like this:
public MapperConfig(
IRoleRepository roleRepository, IActivityRepository activityRepository)
However, I have trouble instatiating the MapperConfig class in the Startup.cs :
services.AddSingleton<IMapper>(provider => new MapperConfiguration(cfg =>
{
cfg.AddProfile(new MapperConfig(
services
.BuildServiceProvider()
.GetService<IRoleRepository, IActivityRepository>()));
}).CreateMapper());
So far I had no problems using the GetService method, because I was passing only one dependency. But if the constructor of the automapper takes multiple parameters, I don't know how to invoke it properly. Any help will be appreciated. Thank you for your time.