title: Castle Windsor inject dependency depending on another parameter in the constructor
body: <p>I need to use Castle Windsor to automatically resolve some kind of services that are dependent on another parameter of the constructor where they are referenced.
  Here is a simple example:</p>
  
  <p><em>the service I want to resolve is:</em></p>
  
  <pre><code>public interface IDependentParameter
  {
     IValue Value;
  
     object Something;
  }
  </code></pre>
  
  <p><em>Implemented by :</em></p>
  
  <pre><code>public class DependentParameter : IDependentParameter
  {
     public DependentParameter(IValue value)
     {
        Value = value;
     }
  
     public IValue Value;
  
     public object Something;
  }
  </code></pre>
  
  <p><em>IValue is another service that I can inject manually into the constructor</em></p>
  
  <p><em>My dependant class looks like:</em></p>
  
  <pre><code>public class DependentClass : IDependentClass 
  {
     IValue Value {get; protected set;}
     IDependentParameter DependentParameter{get; protected set;}
  
     public DependentClass (IValue value, IDependentParameter dependentParameter)
     {
       Value = value;
       DependentParameter= dependentParameter;
  
     }
  }
  </code></pre>
  
  <p><em>The resolution code should be like:</em></p>
  
  <pre><code>var dependant = container.Resolve&lt;IDependantClass&gt;(new { value = knownValue });
  </code></pre>
  
  <p>On other posts, I saw solutions referencing AbstractFactory or TypedFactoryFacility. but the drawbacks I see on that solutions are:</p>
  
  <ul>
  <li>Unable to know just by looking at DependentClass constructor which services are needed (we will see just the factory service).</li>
  <li>How to implement the factory so that it can reference the castle windsor container to resolve IDependentParameter and not the new keyword. I absolutly need an instanciation using castle because I'm creating dynamic proxies instead.</li>
  </ul>