1

我是温莎城堡的新手,对配置文件中的顺序感到困惑。这取自 GettingStarted1 示例。HttpServiceWatcher 类在其构造函数中采用 IFailureNotifier 实现器。但是,无论我如何订购实现此接口的两个组件——AlarmFailureNotifier 和 EmailFailureNotifier——我总是得到 EmailFailureNotifier。我知道您可以覆盖使用参数和“服务查找”参考选择的选项,但我认为在其他机制不使用时使用声明顺序。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="castle"
             type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" />
  </configSections>

  <castle>
    <components>

      <component
        id="httpservicewatcher"
        type="GettingStartedPart1.HttpServiceWatcher, GettingStartedPart1">
      </component>

      <component
        id="alarm.notifier"
        service="GettingStartedPart1.IFailureNotifier, GettingStartedPart1"
        type="GettingStartedPart1.AlarmFailureNotifier, GettingStartedPart1" />

      <component
        id="email.notifier"
        service="GettingStartedPart1.IFailureNotifier, GettingStartedPart1"
        type="GettingStartedPart1.EmailFailureNotifier, GettingStartedPart1" />

      <component
        id="form.component"
        type="GettingStartedPart1.Form1,GettingStartedPart1" />

    </components>

  </castle>
</configuration>
4

2 回答 2

1

Castle 2.0(去年初进入 RTM)解决了这个问题。

Castle 的最新版本是 2.1.1:

http://sourceforge.net/projects/castleproject/files/InversionOfControl/2.1/Castle-Windsor-2.1.1.zip/download

Castle 的版本总是很难找到(他们需要更新他们的网站)。我总是参考项目列表:

http://www.castleproject.org/castle/projects.html

你想要:MicroKernal/Windsor

于 2010-01-24T19:46:54.700 回答
0

我不知道您使用的是哪个版本,但我相信这是前段时间的一个错误,并且已在构建服务器版本中得到纠正。试试那个,看看会发生什么。

此外,您可以使用这样的默认组件:Castle Windsor and default components

于 2008-12-18T18:48:07.960 回答