title: Using AutoMapper.Profile for creating an instance(non-static) mapper
body: <p>I use the following method as described in the following answer to create an instance of a mapper:</p>
  
  <pre><code>var platformSpecificRegistry = AutoMapper.Internal.PlatformAdapter.Resolve&lt;IPlatformSpecificMapperRegistry&gt;();
  platformSpecificRegistry.Initialize();
  
  var autoMapperCfg = new AutoMapper.ConfigurationStore(new TypeMapFactory(), AutoMapper.Mappers.MapperRegistry.Mappers);
  var mappingEngine = new AutoMapper.MappingEngine(_autoMapperCfg);
  </code></pre>
  
  <p>As described by the following question:</p>
  
  <p><a href="https://stackoverflow.com/questions/2734108/automapper-how-to-map-object-a-to-object-b-differently-depending-on-context">AutoMapper How To Map Object A To Object B Differently Depending On Context</a>.</p>
  
  <p>How would I be able to use[reuse] an <a href="https://github.com/AutoMapper/AutoMapper/wiki/Configuration" rel="noreferrer">Automapper profile</a> class like the following to create an instance of a mapper?</p>
  
  <pre><code>public class ApiTestClassToTestClassMappingProfile : Profile
  {
      protected override void Configure()
      {
          base.Configure();
          Mapper.CreateMap&lt;ApiTestClass, TestClass&gt;()
              .IgnoreAllNonExisting();
      }
  }
  </code></pre>
  
  <p>Just to give you an idea on why I require such functionality:
  I register all Automapper Profile classes into my IoC container [CastleWindsor] using the following method :</p>
  
  <pre><code>    IoC.WindsorContainer.Register(Types.FromThisAssembly()
                                         .BasedOn&lt;Profile&gt;()
                                         .WithServiceBase()
                                         .Configure(c =&gt; c.LifeStyle.Is(LifestyleType.Singleton)));
  
      var profiles = IoC.WindsorContainer.ResolveAll&lt;Profile&gt;();
  
      foreach (var profile in profiles)
      {
          Mapper.AddProfile(profile);
      }
  
      IoC.WindsorContainer.Register(Component.For&lt;IMappingEngine&gt;().Instance(Mapper.Engine));
  </code></pre>
  
  <p>While above completely fulfills the need for initializing my static Mapper class, I really dont have any idea how to re-use my Automapper profile classes for creating instance mappers [using non-static mapper].</p>