title: Using Profiles in Automapper to map the same types with different logic with DI support for CustomValue Resolvers
body: <p>I am  trying to use automapper in .net core 1.0.1 application to map types with different logic based on profiles. I have some custom resolvers as well. I am not able to get the DI support in custom resolvers. Here is my code to create mappers.</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>private IMapper CreateMapper(string srcFormName)
  {
      switch (srcFormName)
      {
          case "app1":
              {
                  var configuration1 = new MapperConfiguration(cfg =&gt;
                  {
                      cfg.AddProfile&lt;App1Profile&gt;();
                  });
                   return configuration1.CreateMapper();
              }
          case "app2":
              {
                  var configuration2 = new MapperConfiguration(cfg =&gt;
                  {
                      cfg.AddProfile&lt;App2Profile&gt;();
                  });
                  return configuration2.CreateMapper();
              }
          default:
              return null;
      }
  }
  </code></pre>
  
  <p>I am using the package <a href="https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/2.0.1" rel="nofollow noreferrer">https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/2.0.1</a> and the below line has been added to Startup.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code> services.AddAutoMapper();
  </code></pre>
  
  <p>I need a custom resolver like below</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class NameResolver : IValueResolver&lt;MyType1, MyType2, string&gt;
  {
      private IContextInfo _contextInfo;
  
      //public NameResolver()
      //{
  
      //}
  
      public NameResolver(IContextInfo contextInfo)
      {
          _contextInfo = contextInfo;
      }
  
      public string Resolve(ApplicationForm source, StpApplication destination,
          string destMember, ResolutionContext context)
      {
          _contextInfo.RulesExecuted.Add(DateTime.Now.ToString());
          return source.FirstName + " " + source.MiddleName + " " + source.LastName;
      }
  }
  </code></pre>
  
  <p>But when I try to map, I am getting an exception like parameterless constructor is not present(on my resolver) and fails to map. I believe this could be because of creating my own mapper configuration, but then I don't know to work with multiple profiles without creating own configuration. Please help me.  </p>