title: Using unity xml config to register an interface with nested generics
body: <p>If I have a class that implements a generic interface it works fine to configure it using the unity xml config. </p>
  
  <pre><code>public interface IReader&lt;T&gt; { }
  
  public class Fund { }
  
  public class FundReader : IReader&lt;Fund&gt; { }
  </code></pre>
  
  <p>and the unity xml:</p>
  
  <pre><code>&lt;unity xmlns="http://schemas.microsoft.com/practices/2010/unity"&gt;
    &lt;namespace name="System.ComponentModel" /&gt;
    &lt;namespace name="TestUnityIssue" /&gt;
    &lt;assembly name="TestUnityIssue" /&gt;
    &lt;container&gt;
      &lt;register type="IReader[Fund]" mapTo="FundReader" /&gt;
    &lt;/container&gt;
  &lt;/unity&gt;
  </code></pre>
  
  <p>And this works just using the following code:</p>
  
  <pre><code>var container = new UnityContainer().LoadConfiguration();
  var fundReader = container.Resolve&lt;IReader&lt;Fund&gt;&gt;();
  </code></pre>
  
  <p>However, in some cases there is a wrapper around the type used in the reader. For example, adding the following two classes:</p>
  
  <pre><code>public class Wrapper&lt;T&gt; { }
  
  public class WrappedFundReader : IReader&lt;Wrapper&lt;Fund&gt;&gt; { }
  </code></pre>
  
  <p>and if I add the following to the unity config:</p>
  
  <pre><code>&lt;register type="IReader[Wrapper[Fund]]" mapTo="WrappedFundReader" /&gt;
  </code></pre>
  
  <p>and then try to resolve it using:</p>
  
  <pre><code>var wrappedReader = container.Resolve&lt;IReader&lt;Wrapper&lt;Fund&gt;&gt;&gt;();
  </code></pre>
  
  <p>I get the following exception:</p>
  
  <pre><code>InvalidOperationException - The current type,
  TestUnityIssue.IReader`1[TestUnityIssue.Wrapper`1[TestUnityIssue.Fund]],
  is an interface and cannot be constructed. Are you missing a type
  mapping?
  </code></pre>
  
  <p>I can get around this by configuring it using code instead of xml:</p>
  
  <pre><code>container.RegisterType&lt;IReader&lt;Wrapper&lt;Fund&gt;&gt;, WrappedFundReader&gt;();
  </code></pre>
  
  <p>or I can create an interface that goes between and use that instead:</p>
  
  <pre><code>public interface IWrappedReader&lt;T&gt; : IReader&lt;Wrapper&lt;T&gt;&gt; { }
  
  public class WrappedFundReader : IWrappedReader&lt;Fund&gt;
  </code></pre>
  
  <p>and the config would change to:</p>
  
  <pre><code>&lt;register type="IWrappedReader[Fund]" mapTo="WrappedFundReader" /&gt;
  </code></pre>
  
  <p>It will still give me an instance that I can cast to <code>IReader&lt;Wrapper&lt;Fund&gt;&gt;</code>, but it seems like I should be able to make this work with the unity config. </p>
  
  <p>What am I missing to make this work? </p>
  
  <p>(If also tried creating specific aliases and wasn't able to get that to work either)</p>