title: Conditional Resolve in Castle Windsor
body: <p>I'm developing an ASP.NET MVC 4 web application. The default controller factory has been replaced by a WindsorControllerFactory as suggested <a href="http://docs.castleproject.org/Windsor.Windsor-tutorial-ASP-NET-MVC-3-application-To-be-Seen.ashx" rel="nofollow">here</a>. This is useful because the controllers in this app include references to a couple of services, which are instanciated using injection with Windsor. Each of the services have a proxy to wrap it.</p>
  
  <p>Therefore, we have the following situation:</p>
  
  <ul>
  <li>Two components registered into Castle (one service and one proxy)</li>
  <li>One of them is constructed as a dependency of the other one</li>
  </ul>
  
  <p>It looks something like:</p>
  
  <pre><code>// This URL can be resolved at application startup
  container.Register(Component.For&lt;ITestService&gt;()
      .UsingFactoryMethod(() =&gt; ServiceFactory.CreateService&lt;ITestService&gt;(Settings.Default.ConfigurationProviderUrl))
      .Named(MainServiceComponent)
      .LifeStyle.Transient);
  
  // The URL for this service can be configured during runtime. If it is null or empty it should not be resolved
  container.Register(Component.For&lt;ITestService&gt;()
      .UsingFactoryMethod(() =&gt; ServiceFactory.CreateService&lt;ITestService&gt;(SiteInformation.PublishUrl))
      .Named(PublicationServiceComponent)
      .LifeStyle.Transient);
  
  // This proxy is necessary
  container.Register(Component.For&lt;IConfigurationProxy&gt;()
      .ImplementedBy&lt;ConfigurationProxyWebService&gt;()
      .ServiceOverrides(ServiceOverride.ForKey(typeof(ITestService)).Eq(MainServiceComponent))
      .LifeStyle.Transient);
  
  // This proxy should be created only if SiteInformation.PublishUrl is different from empty or null
  container.Register(Component.For&lt;IConfigurationPublicationProxy&gt;()
      .ImplementedBy&lt;ConfigurationPublicationProxyWebService&gt;()
      .ServiceOverrides(ServiceOverride.ForKey(typeof(ITestService)).Eq(PublicationServiceComponent))
      .LifeStyle.Transient);
  </code></pre>
  
  <p>Is there any way to make Windsor evaluate a condition before resolving? I know it has conditional registration, but I haven't found a way to make conditional resolving... Thank you in advance!</p>