views:

194

answers:

1

Hi all

Is it possible to get Windsor to return different implementations of a service based on a seperate parameter?

For example, if I have a User object which has a Role property, I would like to be able to hydrate this object differently according the the value of Role. I would like to use an IUserService to do this, but have the concrete implementation of IUserService determined by the IoC container.

I think that Ninject offers this functionality as "Contextual Binding" but I'm not sure if Windsor offers it without rolling my own resolution logic?

+3  A: 

No, it is not possible (yet). Take a look here and here. For now take a look at HandlerProvider if it's got what you need. If not, you may need to use ISubDependencyResolver (which is not very complicated actually).

Krzysztof Koźmic
Thanks - I'll give this a try
Graham
I ended up using the ISubDependencyResolver - it works great! Thanks
Graham