Autofac and Automapper new API - ConfigurationStore is gone
<p>I've been using Automapper and Autofac in a .Net app for some time. I configured them this way:</p>

<pre><code>builder.RegisterAssemblyTypes(typeof (OneOfMyMappingProfiles).Assembly)
        .Where(t =&gt; t.IsSubclassOf(typeof (Profile)))
        .As&lt;Profile&gt;();

builder.Register(ctx =&gt; new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers))
        .AsImplementedInterfaces()
        .SingleInstance()
        .OnActivating(x =&gt;
        {
            foreach (var profile in x.Context.Resolve&lt;IEnumerable&lt;Profile&gt;&gt;())
            {
                x.Instance.AddProfile(profile);
            }
        });

builder.RegisterType&lt;MappingEngine&gt;()
            .As&lt;IMappingEngine&gt;().SingleInstance();
</code></pre>

<p>With the latest build of Automapper (4.2) the API has changed and I am having trouble translating to the new API. ConfigurationStore no longer seems to exist. According to the docs, the way to register with an IOC is now like this:</p>

<pre><code> var profiles =
        from t in typeof (AutoMapperRegistry).Assembly.GetTypes()
        where typeof (Profile).IsAssignableFrom(t)
        select (Profile)Activator.CreateInstance(t);

    var config = new MapperConfiguration(cfg =&gt;
    {
        foreach (var profile in profiles)
        {
            cfg.AddProfile(profile);
        }
    });

    For&lt;MapperConfiguration&gt;().Use(config);
    For&lt;IMapper&gt;().Use(ctx =&gt; ctx.GetInstance&lt;MapperConfiguration&gt;().CreateMapper(ctx.GetInstance));
</code></pre>

<p>BUT that is using StructureMap. The first half of this is no problem, but I am not sure how to translate the "For&lt;>.Use()" portion. How do I do that in Autofac?</p>