That's not a bug, it's a known breaking change. Old Windsor was
disregarding which services a component is exposing when doing
ResolveAll, and as a result it would give you contravariant behaviour.
Windsor 3 is not doing that anymore, but it has an extension point that
lets you override that (and control at a fine-grained level) -
IHandlersFilter
So if you write a filter for your IHandle<in T> you can get the old
behaviour.
K
On 22/12/2011 11:13 PM, Sebastiaan wrote:
The ResolveAll with Contravariant seems to behave differently in
Castle Windsor 3.0.0 then with 2.5.4. I've made the below test and ran
it against both versions.
Windsor 2.5.4: Pass
Windsor 3.0.0: Fail
Thought it was kinda useful in 2.5.4. Is this by design or a bug? Can
anyone suggest a workaround if it is by design?
public class Derived : Base { }
public class Base { }
public interface IHandle<in T> { void Handle(T message); }
public class HandleBase : IHandle<Base> { public void Handle(Base
message) { } }
public class HandleDerived : IHandle<Derived> { public void
Handle(Derived message) { } }
[TestFixture]
public class CastleTest
{
[Test]
public void ResolvesUsingContravariant()
{
var container = new WindsorContainer();
container.Register(Component.For<IHandle<Base>>().ImplementedBy<HandleBase>());
container.Register(Component.For<IHandle<Derived>>().ImplementedBy<HandleDerived>());
var list = container.ResolveAll<IHandle<Derived>>();
Assert.AreEqual(2, list.Length);
}
}
--
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.