2011-12-13 1 views
3

기본적으로 이와 같은 서비스를 등록 할 수 있습니다.캐슬 윈저 wcf 시설에 내 모든 서비스를 등록하는 방법

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

그러나 유사한 구성으로 모든 서비스를 등록하는 방법을 알 수 없습니다.

나는 이것이 실행을 기대 한 것은 ... 내가 클라이언트 WCF로 모든 서비스를 등록 할 수 있습니다 방법

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() 
     ); 

? 윈저 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()); 
관련 문제