internal static void AddMapper(this IServiceCollection services, IObjectMapper objectMapper) { if (objectMapper is null) { objectMapper.AddAutoMapperConfiguration(services, confg => {}); services.AddScoped <IMapper, Mapper>(); var mapperService = services.BuildServiceProvider().GetService <IMapper>(); ObjectMapperFactory.SetObjectMapper(new AutoMapAdapter(mapperService)); return; } ObjectMapperFactory.SetObjectMapper(objectMapper); }