8

At the moment this is the way I wire up IMapper instance of Automapper with StructureMap.

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

In net core startup:

var container = new Container(new DefaultRegistry());
container.Populate(services);

services.AddAutoMapper(cfg => cfg.ConstructServicesUsing(container.GetInstance));
Mapper.AssertConfigurationIsValid();

Since Mapper.Instance creates static, how can I register it as an instance? Or what is the proper way to wire it up with StructureMap?

urmat abdykerimov
  • 427
  • 1
  • 7
  • 17
sensei
  • 7,044
  • 10
  • 57
  • 125

0 Answers0