title: Getting and/or ejecting all implementations of a generic interface using structuremap
body: <p>I currently have an interface of</p>
  
  <pre><code>public interface IHandle&lt;T&gt; where T : ICommand
  {
    void Invoke(T command);
  }
  </code></pre>
  
  <p>In structure map I can get any specific implementation of a IHandle with the following type of calls, so I know that all of my handlers exist in StructureMap.</p>
  
  <pre><code>var commandHandler = ObjectFactory.GetInstance&lt;IHandle&lt;SomeCommand&gt;&gt;();
  </code></pre>
  
  <p>However what I would like to do is either get (or eject as thats my eventual goal) all instances if IHandle.</p>
  
  <p>I've tried the following with no success</p>
  
  <pre><code>// compile error because it doesn't have a type
  ObjectFactory.GetAllInstances&lt;IHandle&lt;&gt;&gt;();
  
  // returns 0 items
  ObjectFactory.GetAllInstances&lt;IHandle&lt;ICommand&gt;&gt;();
  
  // has runtime error of "Cannot create arrays of open type."
  ObjectFactory.GetAllInstances(typeof(IHandle&lt;&gt;));
  </code></pre>
  
  <p>Does anyone know how to get all instances of a generic interface?</p>
  
  <p>Thanks for any help</p>