3

基本的には、このようなサービスを 1 つ登録できます。

Container.Register(Component.For<IMyService>()
                       .AsWcfClient(new DefaultClientModel() { 
                            Endpoint = WcfEndpoint
                                   .BoundTo(new NetNamedPipeBinding())
                                   .At("net.pipe://localhost/MyService") })
                       .LifeStyle.PerWebRequest);

しかし、すべてのサービスを同様の構成で登録する方法がわかりませんでした。

私が実行したいと思っていたのはこれです...

Container.Register(
    AllTypes.FromAssemblyNamed("My.Server.MyContracts")
        .Pick().If(x => x.Name.EndsWith("Service"))
        .Configure(configurer => configurer.Named(configurer.Implementation.Name)
                .AsWcfClient(new DefaultClientModel
                {
                    Endpoint = WcfEndpoint.BoundTo(new NetNamedPipeBinding())
                    .At(string.Format("net.pipe://localhost/{0}", configurer.Named(configurer.Implementation.Name)).Substring(1))
                }))
            .LifestylePerWebRequest()
        );

すべてのサービスを wcf クライアントとして登録するにはどうすればよいですか?

4

1 に答える 1

4

Windsor 3.0 を使用すると、 AllTypesの代わりにTypeを使用して、サービス インターフェイスを登録し、次のようにクライアント側の動的プロキシを生成するだけで済みます。

Container
    .Register(
        Types
            .FromAssemblyNamed("My.Server.MyContracts")
            .Pick()
            .If(x => x.Name.EndsWith("Service"))
            .Configure(
                configurer => configurer.Named(configurer.Implementation.Name)
                                  .AsWcfClient(new DefaultClientModel
                                                   {
                                                       Endpoint = WcfEndpoint
                                                           .BoundTo(new NetNamedPipeBinding())
                                                           .At(string.Format(
                                                                       "net.pipe://localhost/{0}",
                                                                       configurer.Name.Substring(1)))
                                                   }))
            .LifestylePerWebRequest());
于 2012-01-10T08:39:58.510 に答える