title: AutoMapper Custom Type Converter not working
body: <p>I am using <a href="https://github.com/TroyGoode/PagedList">Troy Goode's PagedList</a> to provide paging information in my WebApi.  His package returns an IPagedList that implements IEnumerable but also contains custom properties such as IsLastPage, PageNumber, PageCount, etc.</p>
  
  <p>When you try to return this class from a WebApi controller method (such as the GET), the Enumerable is serialized, but the custom properties are not.  So, I thought I would use AutoMapper and write a custom type converter to convert to a class such as this:</p>
  
  <pre><code>public class PagedViewModel&lt;T&gt;
  {
      public int FirstItemOnPage { get; set; }
      public bool HasNextPage { get; set; }
      public bool HasPreviousPage { get; set; }
      public bool IsFirstPage { get; set; }
      public bool IsLastPage { get; set; }
      public int LastItemOnPage { get; set; }
      public int PageCount { get; set; }
      public int PageNumber { get; set; }
      public int PageSize { get; set; }
      public int TotalItemCount { get; set; }
      public IEnumerable&lt;T&gt; rows { get; set; }
  }
  </code></pre>
  
  <p>Since I move the Enumerable into a distinct property, the serialization handles it perfectly.  So, I sat down and wrote a custom type converter like this:</p>
  
  <pre><code>public class PagedListTypeConverter&lt;T&gt; : ITypeConverter&lt;IPagedList&lt;T&gt;, PagedViewModel&lt;T&gt;&gt;
  {
      public PagedViewModel&lt;T&gt; Convert(ResolutionContext context)
      {
          var source = (IPagedList&lt;T&gt;)context.SourceValue;
          return new PagedViewModel&lt;T&gt;()
          {
              FirstItemOnPage = source.FirstItemOnPage,
              HasNextPage = source.HasNextPage,
              HasPreviousPage = source.HasPreviousPage,
              IsFirstPage = source.IsFirstPage,
              IsLastPage = source.IsLastPage,
              LastItemOnPage = source.LastItemOnPage,
              PageCount = source.PageCount,
              PageNumber = source.PageNumber,
              PageSize = source.PageSize,
              TotalItemCount = source.TotalItemCount,
              rows = source
          };
      }
  }
  </code></pre>
  
  <p>And then set it up in my configuration like this:</p>
  
  <pre><code>Mapper.CreateMap&lt;IPagedList&lt;Department&gt;, PagedViewModel&lt;Department&gt;&gt;().ConvertUsing(new PagedListTypeConverter&lt;Department&gt;());
  </code></pre>
  
  <p>But, when I try to call it like this:</p>
  
  <pre><code>var x = Mapper.Map&lt;IPagedList&lt;Department&gt;, PagedViewModel&lt;Department&gt;&gt;(departments);
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Missing type map configuration or unsupported mapping.</p>
    
    <p>Mapping types: IPagedList<code>1 -&gt; PagedViewModel</code>1
    PagedList.IPagedList<code>1[[Provision.DomainObjects.Department,
    Provision.DomainObjects, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=null]] -&gt;
    Provision.DomainObjects.PagedViewModel</code>1[[Provision.DomainObjects.Department,
    Provision.DomainObjects, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=null]]</p>
    
    <p>Destination path: PagedViewModel`1</p>
    
    <p>Source value:
    PagedList.StaticPagedList`1[Provision.DomainObjects.Department]</p>
  </blockquote>
  
  <p>How can I make this work?</p>