title: Generic mapper instead of having numerous individual mappers
body: <p>I am using <code>ASP.NET MVC 3</code> with <code>Razor</code> and <code>Autofac</code> for dependency injection.</p>
  
  <p>I am thinking of creating a generic mapper.  Currently I am using <code>AutoMapper</code> for the mapping between my domain and view model.  It can be any mapping framework, but I am using AutoMapper .</p>
  
  <p>Here is my <code>IMapper</code> interface:</p>
  
  <pre><code>public interface IMapper
  {
       object Map(object source, Type sourceType, Type destinationType);
  }
  </code></pre>
  
  <p>I then have an IBankMapper interface that implements this IMapper interface.  The reason why I did it like this is because I can have many different mappers.  Using dependency injection I can know what instance I can inject.  So for IBankMapper I will inject BankMapper, ICategoryMapper I will inject CategoryMapper.</p>
  
  <p><code>IBankMapper</code> interface:</p>
  
  <pre><code>public interface IBankMapper : IMapper
  {
  }
  </code></pre>
  
  <p><code>BankMapper</code> class:</p>
  
  <pre><code>public class BankMapper : IBankMapper
  {
       static BankMapper()
       {
            Mapper.CreateMap&lt;Bank, EditBankViewModel&gt;();
            Mapper.CreateMap&lt;EditBankViewModel, Bank&gt;();
       }
  
       public object Map(object source, Type sourceType, Type destinationType)
       {
            return Mapper.Map(source, sourceType, destinationType);
       }
  }
  </code></pre>
  
  <p>As the program grows so will the mapper classes.  Is there a way that I can create a generic mapper, one that can be used in the whole application?  Is this possible?</p>