Results 1 to 3 of 3

Thread: Autowiring Multiple Implementations into List<Interface> Constructor Parameter

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Default Autowiring Multiple Implementations into List<Interface> Constructor Parameter

    Hi all,

    I would like to have an interface IFoo, with is implemented by two classes: Bar and Bazz. Can I have a third class, Booya, such that:

    public Booya(List<IFoo> foos)
    {
    ...
    }

    is autowired properly with:

    <object id="Booya" type="Full.Namespace.Of.Booya" autowire="constructor" />
    <object id="Bar" type="Full.Namespace.Of.Bar" autowire="constructor" />
    <object id="Bazz" type="Full.Namespace.Of.Bazz" autowire="constructor" />

    in my XML Spring configuration?

    Thanks for your time!

  2. #2
    Join Date
    Jan 2012
    Posts
    2

    Default

    I should probably also mentioned that I've tried this with a fairly "out of the box" Spring.NET installation on a web app. It's giving me the following error, though:

    "Unsatisfied dependency expressed through constructor argument with index 0 of type [System.Collections.Generic.List`1[...]]]] : No unique object of type [System.Collections.Generic.List`1[[..]] is defined..."

    It isn't too surprising, since it just seems to not be working with the List object properly. I was wondering if there were any alternative methods or helper objects around that might make it work properly.

  3. #3
    Join Date
    Apr 2011
    Posts
    57

    Default

    I don't think autowiring for collections is working in the current spring.net release.

    It certainly isn't for dictionaries: https://jira.springsource.org/browse/SPRNET-1445

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •