Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Registering a WcfClient in the container when the URI not yet known

At the time I am registering a new WCF endpoint I do not know what the 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 some way I can retrieve the URI from the container at the time the IMyService instance is requested (this is when it is known)?

Is there a factory method/dynamic parameter sort of thing that could be used?

like image 882
KevinT Avatar asked Oct 06 '22 11:10

KevinT


1 Answers

It looks like you're able to do so 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 the given dynamic resolution delegate at the point when an IMyService is first resolved.

like image 140
jancow Avatar answered Oct 10 '22 11:10

jancow