【问题标题】:Castle Windsor IOC and Order of Appearance in Config FileCastle Windsor IOC 和配置文件中的出现顺序
【发布时间】:2008-12-18 18:25:13
【问题描述】:

我是温莎城堡的新手,对配置文件中的顺序感到困惑。这取自 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>

【问题讨论】:

    标签: castle-windsor


    【解决方案1】:

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

    城堡的最新版本是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

    【讨论】:

    • 嗨,Eric,我们如何改进下载过程?为什么你觉得它很棘手?
    • 你好毛里西奥!!!我认为与我交谈的大多数人感到困惑的是这个页面:castleproject.org/castle/download.html 许多人最终下载了 RC3,因为它似乎是唯一“完整”的包。也许在每个标题下插入 cmets:Windsor 2.1 - Castle MicroKernel 是控制容器的反转,旨在实现可扩展性(在正常字体中,在大粗体标题下)。只是一个建议!继续努力!
    【解决方案2】:

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

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

    【讨论】:

    • 我下载了 CastleProject-1.0-RC3.msi。这是最新版本吗?
    • 这不是最新版本,您需要从源代码管理中下载主干(如果您不想自己构建它,只需在此处从构建器服务器下载最后一个成功构建:@ 987654322@)
    猜你喜欢
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    • 1970-01-01
    相关资源
    最近更新 更多