代码之家  ›  专栏  ›  技术社区  ›  Andrej Golcov

使用WCF集成工具为WCF代理服务器配置Castle Windsor XML

  •  1
  • Andrej Golcov  · 技术社区  · 16 年前

    目前,我们使用WCF集成工具在温莎容器中对WCF代理进行编程注册。例如:

    container.Register(
        Component.For<CalculatorSoap>()
          .Named("calculatorSoap")
          .LifeStyle.Transient
          .ActAs(new DefaultClientModel
          {
            Endpoint = WcfEndpoint.FromConfiguration("CalculatorSoap").LogMessages()
          }
          )
          );
    

    是否有任何方法可以通过windsor xml配置文件来实现这一点?我在谷歌上找不到这方面的任何样本。

    提前谢谢

    2 回复  |  直到 16 年前
        1
  •  2
  •   Andrej Golcov    16 年前

    Castle WCF集成设施存储库( http://github.com/castleproject/Castle.Facilities.Wcf )现在包含来自windsor配置文件的wcf客户端注册示例:

    <?xml version='1.0' encoding='utf-8' ?>
    <configuration>
    <facilities>
        <facility id='wcf' 
                  type='Castle.Facilities.WcfIntegration.WcfFacility,
                        Castle.Facilities.WcfIntegration' />
    </facilities>
    
    <components>
        <component id='calculatorSoap'
                   type='Demo.CalculatorSoap, Demo.UnitTests'
                   wcfEndpointConfiguration='CalculatorSoap'>
        </component>
    </components>
    </configuration>
    

    这就是我要找的。 谢谢你的帮助。

    注: 注意生活方式。在通常情况下,WCF代理必须有短暂的生活方式才能在对象发布时关闭。虽然默认的温莎生活方式是单件,在这种情况下,WCF代理将关闭对容器的处置。

    问候,Andrej

        2
  •  1
  •   Krzysztof Kozmic    16 年前

    使用 IWindsorInstaller 建议通过代码进行注册。配置用于配置(和传统方案)。

    我将为此创建两个安装程序,并基于编译标志使用其中一个安装程序;

    var installer = 
    #if DEBUG
    new TestingServiceInstaller();
    #elseif
    new ProductionServiceInstaller();
    #endif
    
    container.Install(installer);