title: Castle Windsor register multiple instances
body: <p>I am trying to register a different instance of my database depending upon the constructor name. I am familiar with the "first wins" concept in Castle Windsor, but apparently I don't fully understand it. </p>
  
  <p>I would like uaxDB parameter name below to signal ControllerInstaller to give me the instance with UAXmongoURL, UAXmongoConnection parameters. Instead I am getting the first instance, with USERmongoURL and USERmongoconnection parameters. So...first wins, but even when I used named instances? How can I fix so that the named instance trumps any default ordering? </p>
  
  <p>Note I don't just want to swap the order of the two components, because I'm about to have yet more instances so I need to scale beyond 2....said another way, I really need to understand what I'm doing wrong. </p>
  
  <pre><code>// Trying to avoid this constructor declaration in favor of the uncommented constructor
  // public DBViewerModel(IMongoConnection devDB, IMongoConnection uaxDB, IMongoConnection prodDB)
  public DBViewerModel(IMongoConnection mongoConnection)
  {
      //this.devMongoConnection = devDB;
      //this.uaxMongoConnection = uaxDB;
      //this.prodMongoConnection = prodDB;
      this.mongoConnection = mongoConnection;
  }
  </code></pre>
  
  <p>With registration...</p>
  
  <pre><code>container.Register(
      Component
          .For&lt;IMongoConnection&gt;()
          .Named("dataDB")
          .ImplementedBy&lt;MongoConnection&gt;()
          .DependsOn(Property.ForKey("DBlocation").Eq(USERmongoURL),
                     Property.ForKey("DB").Eq(USERmongoCollection))
          .LifeStyle.PerWebRequest,
  
      Component
          .For&lt;IMongoConnection&gt;()
          .Named("uaxDB")
          .ImplementedBy&lt;MongoConnection&gt;()
          .DependsOn(Property.ForKey("DBlocation").Eq(UAXmongoURL),
                     Property.ForKey("DB").Eq(UAXmongoCollection))
          .LifeStyle.PerWebRequest);
  </code></pre>