Automapper and StructureMap proper .net Core instance registration

I am currently connecting an instance of IMapper Automapper with StructureMap.

public class DefaultRegistry : Registry { public DefaultRegistry() { Scan(o => { o.AddAllTypesOf<Profile>(); }); For<IMapper>().Use(() => Mapper.Instance); } } 

At the start of the network kernel:

  var container = new Container(new DefaultRegistry()); container.Populate(services); services.AddAutoMapper(cfg => cfg.ConstructServicesUsing(container.GetInstance)); Mapper.AssertConfigurationIsValid(); 

Since Mapper.Instance creates statics, how can I register it as an instance? Or how to connect it to StructureMap?

+5
source share

Source: https://habr.com/ru/post/1263382/


All Articles