当URI尚未知道时,在容器中注册WcfClient

Kev*_*inT 5 castle-windsor wcf-client

在我注册新的WCF端点时,我不知道URI是什么......

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));
}
Run Code Online (Sandbox Code Playgroud)

有没有什么方法可以在请求IMyService实例时从容器中检索URI(这是在知道的时候)?

是否有工厂方法/动态参数可以使用的东西?

小智 4

看起来您可以在 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??? )));
}
Run Code Online (Sandbox Code Playgroud)

Windsor 将在首次解析 IMyService 时尝试使用给定的动态解析委托来解析端点。


归档时间:

查看次数:

592 次

最近记录:

13 年,8 月 前