Hi

Yeah, I think I could do it with ServiceOverrides - or actually with 
DependsOn - but from where?

If I understand it correctly I would need to place an override on the 
registration of Bar, which is exactly want I don't want to do. If I simply 
wanted to configure which one should be used that would be easy, but that's 
not what I want.

What I need is someplace where I can hook a facility in that can modify the 
ComponentRegistration object or can do something else that has the same 
effect.

So that when I call 
container.Register(ComponentRegistration.For<IBar>().ImplementedBy<Bar>()); 
something happens that connects the second IFoo (from example in first 
post) to the IFoo dependency in Bar, without it being part of the 
configuration of Bar.


/kim

On Wednesday, 2 May 2012 16:00:48 UTC+2, Patrick Steele wrote:
>
> Wouldn't service overrides work in this case? 
>
>
> http://docs.castleproject.org/Windsor.Registering-components-one-by-one.ashx#Supplying_the_component_for_a_dependency_to_use_Service_override_9
>  
>
> --- 
> Patrick Steele 
> http://weblogs.asp.net/psteele 
>
>
> On Wed, May 2, 2012 at 7:11 AM, Kim Birkelund wrote: 
> > Hi 
> > 
> > I've been looking for and trying to build a facility that provides the 
> same 
> > support as Guice's annotatedWith 
> > (http://code.google.com/p/google-guice/wiki/BindingAnnotations) but for 
> > Windsor. 
> > 
> > Basically what I want is to be able to make a registrations like: 
> > 
> > container.Register(Component.For<IFoo>().Instance(foo1)); 
> > 
> > 
> container.Register(Component.For<IFoo>().Instance(foo2).AttributedWith(typeof(SomeAttribute)));
>  
>
> > 
> > And then declare a type depending on IFoo: 
> > 
> > public class Bar { 
> >    public Bar([Some]IFoo foo) {...} 
> > } 
> > 
> > Which would then get the foo2 instance instead of foo1 which it normally 
> > would. 
> > 
> > I have been unable to find something that already provides this and so 
> far 
> > haven't had luck enough to implement it myself, though I'll keep trying 
> :) 
> > 
> > I've been able to created the extension method allowing me to do the 
> > registration and added the attribute info (using 
> .AddAttributeDescription) 
> > to the registration - currently it just a key/value pair containing a 
> key 
> > and the fully qualified name of the attribute type. 
> > 
> > I've tried using the DependencyResolving event on the kernel but can't 
> > figure out 1) how to get all the registered components so I can figure 
> out 
> > which has the attribute I'm looking for, and 2) how to replace the 
> > dependency that has already been resolved. 
> > 
> > Any suggestions of how to do this i welcomed, also if anyone knows how I 
> > could support syntax like .AttributedWith<SomeAttribute>() instead of 
> > passing the type using typeof I'd like that too. 
> > 
> > 
> > Regards 
> > 
> > Kim 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Castle Project Users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/castle-project-users/-/Aeq4f5aEligJ. 
> > To post to this group, send email to 
> [email protected]. 
> > To unsubscribe from this group, send email to 
> > [email protected]. 
> > For more options, visit this group at 
> > http://groups.google.com/group/castle-project-users?hl=en. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/castle-project-users/-/MytyPh_NDysJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to