title: Castle Windsor: How do I inject all implementations of interface into a ctor?
body: <p>I've written an interface which is implemented by multiple classes. I want to write a Service class which will have all the registered implementations injected into its ctor.</p>
  
  <p>The only solution I can think of is to call the Service Locator within the ctor and ask it to Resolve() all implementations.</p>
  
  <p>Ideally I would like something like this -</p>
  
  <pre><code>interface IVehicle
  {
      void Start();
  }
  
  class Car : IVehicle
  {
      public void Start()
      {
          Console.WriteLine("Car started.");
      }
  }
  
  class Truck : IVehicle
  {
      public void Start()
      {
          Console.WriteLine("Truck started.");
      }
  }
  
  class Motorbike : IVehicle
  {
      public void Start()
      {
          Console.WriteLine("Motorbike started.");
      }
  }
  
  class VehicleService
  {
      // How do I inject all implementations of IVehicle?
      public VehicleService(IEnumerable&lt;IVehicle&gt; vehicles)
      {
          foreach (var vehicle in vehicles)
          {
              vehicle.Start();
          }
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong> - I should mention I'm using Castle Windsor.</p>