title: Dynamic selection of interface implementation using IoC
body: <p>I have a situation where the implementation of an interface is determined at runtime. For example, I check a string and then determine which subclass to use, without IoC it looks like the following:</p>
  
  <pre><code>if (fruitStr == "Apple")
  {
      new AppleImpl().SomeMethod();
  }
  else
  {
      new BananaImpl().SomeMethod();
  }
  </code></pre>
  
  <p>Both classes <code>AppleImpl</code> and <code>BananaImpl</code> are implementation of the same interface, say <code>IFruit</code>.</p>
  
  <p>How can this be done using IoC/Dependency Injection, especially in <strong>Castle Windsor</strong>?</p>