i am using automapper to map from dtos to domain and vice versa; i am using custom type converter to do the conversion but i want to inject dependencies into my converter class using simple injector ioc; i can't do that. please tell me how to achieve that?
public class DtoToEntityConverter : ITypeConverter<Dto, Entity>
{
private readonly IEntityRepository _entityRepository;
public DtoToEntityConverter (IEntityRepository entityRepository )
{
_entityRepository = entityRepository ;
}
public Entity Convert(ResolutionContext context)
{
}
}
You'll need to configure services via AutoMapper:
var container = ConfigureSimpleInjectorContainer();
Mapper.Initialize(cfg => {
cfg.ConstructServicesUsing(type => container.GetInstance(type));
// The rest of your initialization
});