Windsor and configuring arrays of components

9 views
Skip to first unread message

Cristian Libardo

unread,
May 12, 2007, 12:15:56 PM5/12/07
to castle-pro...@googlegroups.com
Hi, I'm kinda new to the windsor contianer and would like your help to get
this straight.

I have this "multiple site" component which keeps a list of "sites". The
"sites" are configured as components and the "multple site" is component
with an array parameter. I thought I could reference the "single sites" for
the array using the ${componentid} construct.

But a Castle.MicroKernel.SubSystems.Conversion.ConverterException is always
thrown when I resolve my "multiple site". I can get it to work by adding a
ITypeConverter but I strongly feel I'm doing something wrong.

What am I doing wrong? (code excerpts below)

Thanks
/Cristian

The class:

namespace CastleWindsorTest
{
public class MultipleSite : ISite
{
public MultipleSite(Site[] sites)
...


The configuration:

<component id="site" service="CastleWindsorTest.ISite,
CastleWindsorTest" type="CastleWindsorTest.Site, CastleWindsorTest">
<parameters>
<RootPage>666</RootPage>
</parameters>
</component>

<component id="site2" service="CastleWindsorTest.ISite,
CastleWindsorTest" type="CastleWindsorTest.Site, CastleWindsorTest">
<parameters>
<RootPage>42</RootPage>
</parameters>
</component>

<component id="multipleSite" service="CastleWindsorTest.ISite,
CastleWindsorTest" type="CastleWindsorTest.MultipleSite, CastleWindsorTest">
<parameters>
<sites>
<array>
<item>${site}</item>
<item>${site2}</item>
</array>
</sites>
</parameters>
</component>

_________________________________________________________________
Vårens klädmode på MSN http://salongk.msn.se/

Ayende Rahien

unread,
May 12, 2007, 12:39:27 PM5/12/07
to castle-pro...@googlegroups.com
The type that you expose is Site[], but the services are ISite

Hamilton Verissimo

unread,
May 12, 2007, 6:58:46 PM5/12/07
to castle-pro...@googlegroups.com
On top of that, it seems that this stuff is data, instead of services.
Maybe they shouldnt be managed by Windsor?


--
Cheers,
hamilton verissimo
ham...@castlestronghold.com
http://www.castlestronghold.com/

Cristian Libardo

unread,
May 13, 2007, 10:46:33 AM5/13/07
to castle-pro...@googlegroups.com
Thank you Ayende =) I removed the "service" parts in my site and site2
configurations and got it to work the way I wanted.

Hammet, just to make sure I'm understanding you. One of the things I like
the most about windsor was that I can configure my services/classes right
were they are defined. Will I run into trouble doing this throughout?

Now, in case anyone is interested in why I'm seeing the "sites" as
components. I have this service, "ISite", that that knows which page is the
root page (and eventually other stuff as well). In certain installations I'd
like to change my "default site" implementation with a "multiple site"
implementation that does stuff depending on the domain name. Since the
"default site" implementation already has all I need, and I don't want to
make any xml parsing, I'm adding other sites in my "multiple site". Any
criticism is of course very welcome.

Thanks,
Cristian

_________________________________________________________________
Kolla in coola trailern till Die Hard 4
http://specials.se.msn.com/diehard4/default.aspx

Reply all
Reply to author
Forward
0 new messages