Automapper和StructureMap正确的实例注册.net核心

ame*_*els 7 c# structuremap automapper

目前,这是我使用StructureMap连接自动映射器的IMapper实例的方式.

public class DefaultRegistry : Registry
    {
        public DefaultRegistry()
        {
            Scan(o =>
            {
                o.AddAllTypesOf<Profile>();
            });

            For<IMapper>().Use(() => Mapper.Instance);
        }
    }
Run Code Online (Sandbox Code Playgroud)

在网络核心创业中:

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

    services.AddAutoMapper(cfg => cfg.ConstructServicesUsing(container.GetInstance));
    Mapper.AssertConfigurationIsValid();
Run Code Online (Sandbox Code Playgroud)

由于Mapper.Instance创建静态,如何将其注册为实例?或者使用StructureMap连接它的正确方法是什么?