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 <[email protected]> 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 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