Castle Windsor IOC and order of appearance in the config file

I'm new to Castle Windsor and confused about ordering in the config file. This is taken from the GettingStarted1 example. The HttpServiceWatcher class uses the IFailureNotifier constructor in it. However, no matter how I order two components that implement this interface - AlarmFailureNotifier and EmailFailureNotifier - I always get EmailFailureNotifier. I know that you can override which one is selected using parameters and a link to "service lookup", but I thought the order of declaration is used when other mechanisms are not.

<?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>

      

+1


source to share


2 answers


This has been allowed since Castle 2.0 (which went through RTM early last year).

The latest version of Castle is 2.1.1:

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



Castle releases are always a bit hard to find (they need to update their site). I always refer to the list of projects:

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

You want: MicroKernal / Windsor

+1


source


I don't know which version you are using, but I believe it was a bug a while ago and has been fixed in the build server version. Try this and see what happens.



Alternatively, you can use the default components as follows: Windsor Castle and default components

0


source







All Articles