2011-12-13 10 views
3

基本的に私はこのようなサービスを1つ登録できます。どのように私はすべてのサービスをcastle windsor wcf facilityに登録できますか

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クライアントとして、すべてのサービスを登録することができますか?ウィンザー3.0を使用して

答えて

4

、あなたはちょうどそれがサービス・インターフェースを登録し、そのようにあなたのために、クライアント側の動的プロキシを生成するように代わりAllTypesタイプを使用する必要があります。

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()); 
関連する問題