title: Autofac with Open Generics and Type Specified at Runtime
body: <p>The documentation states that Autofac supports open generics and I am able to register and resolve in a basic case like so:</p>
  
  <p>Registration:</p>
  
  <pre><code>builder.RegisterGeneric(typeof(PassThroughFlattener&lt;&gt;))
         .As(typeof(IFlattener&lt;&gt;))
         .ContainerScoped();
  </code></pre>
  
  <p>Resolve:</p>
  
  <pre><code>var flattener = _container.Resolve&lt;IFlattener&lt;Address&gt;&gt;();
  </code></pre>
  
  <p>The above code works just fine.  However, assuming that I will not know the type provided to IFlattener until runtime, I want to do something like this:</p>
  
  <pre><code>object input = new Address();
  var flattener = (IFlattener)_container.Resolve(typeof(IFlattener&lt;&gt;), new TypedParameter(typeof(IFlattener&lt;&gt;), input.GetType()));
  </code></pre>
  
  <p>Is this possible with AutoFac?  I got the idea from the following using StructureMap:</p>
  
  <p><a href="http://structuremap.sourceforge.net/Generics.htm" rel="noreferrer">http://structuremap.sourceforge.net/Generics.htm</a></p>
  
  <p>I'm trying to achieve the same goal outlined in this article.</p>