在我注册新的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));
}
有没有什么方法可以在请求IMyService实例时从容器中检索URI(这是在知道的时候)?
是否有可以使用的工厂方法/动态参数?
答案 0 :(得分: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??? )));
}
Windsor将尝试在首次解析IMyService时使用给定的动态解析代理来解析端点。
答案 1 :(得分:0)
我认为您希望使用UsingFactoryMethod来创建服务。
以下链接可能有用
ravendb, castle IoC ,Wcf facility - doc session liefstyle
Using Castle Windsor WcfFacility to create client endpoints
http://www.mail-archive.com/castle-project-users@googlegroups.com/msg09012.html(这个代码看起来与你需要的代码类似)
https://stackoverflow.com/questions/10250077/problems-using-castle-windsor-factory-method
Passing parameters to UsingFactoryMethod in Castle Windsor
Castle Windsor: UsingFactoryMethod can't instantiate with a weird error