you may want to verify that the same instance is registered for both
IFoo and IFooX.
if the registration ends up being
container.Register(Component.For<IFoo>().ImplementedBy<Sut>());
container.Register(Component.For<IFooX>().ImplementedBy<Sut>());
Assert.AreEqual(container.Resolve<IFoo>(),
container.Resolve<IFooX>());
//fails
the test will fail because there is a unique instance for each
service.
If you use component forwarding, 1 instance is maintained for all
services.
container.Register(Component.For<IFoo>().Forward<IFooX>().ImplementedBy<Sut>());
Assert.AreEqual(container.Resolve<IFoo>(),
container.Resolve<IFooX>());
//passes
On Sep 3, 1:13 pm, "Jan Limpens" <[EMAIL PROTECTED]> wrote:
> sweet! thanks!
>
>
>
> On Wed, Sep 3, 2008 at 12:42 PM, Craig Neuwirt <[EMAIL PROTECTED]> wrote:
> > something like
>
> > Kernel.Register(
> > AllTypes.FromAssembly(Assembly.GetExecutingAssembly())
> > .BasedOn(typeof(IValidatorOf<>))
> > .WithService.Select((t,b) => t.GetInterfaces())
> > .Configure(delegate(ComponentRegistration c)
> > {
> > c.LifeStyle.Is(LifestyleType.Transient);
> > }),
> > );
>
> > On Wed, Sep 3, 2008 at 10:27 AM, Jan Limpens <[EMAIL PROTECTED]> wrote:
>
> >> Hello,
>
> >> this test meets my expectations:
>
> >> [TestFixture]
> >> public class KernelTests
> >> {
> >> [Test]
> >> [ExpectedException(typeof(ComponentNotFoundException))]
> >> public void KernelDoesNotResolveEntitiesBySubInterface()
> >> {
> >> var container = new WindsorContainer();
> >> container.Register(Component.For<IFoo>().ImplementedBy<Sut>());
> >> container.Resolve<IFooX>();
> >> }
>
> >> public class Sut : IFooX, IBar { }
> >> public interface IFooX : IFoo { }
> >> public interface IFoo { }
> >> public interface IBar { }
> >> }
>
> >> but is there a way to tell the container to also register all (or
> >> some) other interfaces a (group of) class subscribe to?
> >> In my case I want to register a whole bunch of validators that
> >> implement IValidator<T> : IValidator.
> >> I would like to avoid to have to register all of them one by one. I
> >> might forget one. On the other hand I cannot resolve them by
> >> IValidator, because that would remove their meaning of live.
>
> >> --
> >> Jan
> >> ___________________
> >> [EMAIL PROTECTED]
> >>www.limpens.com
> >> +55 (11) 3082-1087
> >> +55 (11) 3097-8339
>
> --
> Jan
> ___________________
> [EMAIL PROTECTED]
> +55 (11) 3082-1087
> +55 (11) 3097-8339
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---