title: How to register AutoMapper 4.2.0 with Simple Injector
body: <p>Updated to AutoMapper 4.2.0, and following the migration guide available here: <a href="https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API/f4784dac61b91a0df130e252c91a0efd76ff51de#preserving-static-feel" rel="nofollow noreferrer">https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API/f4784dac61b91a0df130e252c91a0efd76ff51de#preserving-static-feel</a>. Trying to translate code on that page for StructureMap to Simple Injector. Can someone show me what this code looks like in Simple Injector?</p>
  
  <p>StructureMap</p>
  
  <pre><code>public class AutoMapperRegistry : Registry
  {
      public AutoMapperRegistry()
      {
          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>Simple Injector</p>
  
  <pre><code>?
  </code></pre>