Register WcfClient in container when URI is not yet known

While I'm registering a new WCF endpoint, I don't know what a URI is ...

public void Install(IWindsorContainer container, IConfigurationStore store)
{
   var defaultClientModel = new DefaultClientModel
   {
     Endpoint = WcfEndpoint
       .ForContract<IMyService>()
       .BoundTo(new WSHttpBinding(SecurityMode.None))
       .At(  URI??? )
   };

   container.Register(WcfClient.ForChannels(defaultClientModel));
}

Is there a way to get the URI from the container while requesting an IMyService instance (this is when it is known)?

Is there a factory method / dynamic parameter that can be used?

+5
source share
2 answers

It looks like you can do this using the following syntax in Windsor 3.1:

public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
    Component.For<IMyService>()
    .AsWcfClient()
    .DependsOn((k, d) =>
        d["EndPoint"] = WcfEndpoint.BoundTo(new WSHttpBinding(SecurityMode.None)).At( URI??? )));
}

Windsor will attempt to resolve the endpoint using this dynamic resolution delegate at the moment IMyService is first enabled.

+4
source

All Articles