title: structuremap inject a dictionary list of interfaces
body: <p>Say I have a list of protocol handlers, and the client service knows which protocol to use based on an enum value, it would be nice to selected the protocol from the list of i/fs passed in.</p>
  
  <p>How can I achieve this in StructureMap?:</p>
  
  <pre><code>   public EmailTransportService(interfaces...,
                                 IDictionary&lt;EmailAccountType, IEmailTransportHandler&gt; transportHandlers)
  </code></pre>
  
  <p>At the moment, I'm using ObjectFactory with get named instance like so:</p>
  
  <pre><code>  _emailTransportHandlers = new Dictionary&lt;EmailAccountType, string&gt;
                                          {
                                              {EmailAccountType.Pop3, "Pop3Handler"},
                                              {EmailAccountType.IMAP, "IMapHandler"}
                                          };
  </code></pre>
  
  <p>then resolving like so:</p>
  
  <pre><code> private IEmailTransportHandler GetTransportHandler(EmailAccountType accountType)
          {            
              return ObjectFactory.GetNamedInstance&lt;IEmailTransportHandler&gt;(_emailTransportHandlers[accountType]);
          }
  </code></pre>
  
  <p>but I don't like this as its difficult within my unit tests to verify the calls to the handlers.</p>
  
  <p>My service registry looks like so:</p>
  
  <pre><code> public EmailTransportServiceRegistry()
   {
              Scan(x =&gt;
                       {
                          ....                      
                       });
  
              For&lt;IEmailTransportHandler&gt;().Use&lt;ActiveUpPop3Handler&gt;().Named("Pop3Handler");
              For&lt;IEmailTransportHandler&gt;().Use&lt;ActiveUpIMap4Handler&gt;().Named("IMapHandler");
  }
  </code></pre>
  
  <p>So basically I'm relying on named instances based on the dictionary list of protocol types.</p>