In Windsor, the first registration for a service becomes the default (see http://stw.castleproject.org/Windsor.Registering-components-one-by-one.ashx#Register_more_components_for_the_same_service:_4 )
You'll probably want to put a name to the second component registered. -- Mauricio On Sat, Sep 11, 2010 at 9:52 AM, Belvasis <[email protected]>wrote: > Hi, > > I have a situation where i want to register an existing instance of a > service with a specific key.Beside this > i need the serviceregistration that gives me a new instance everytime i > call Resolve<>(). > So i did the following: > > IService pS1 = new TestService(); > > pContainer.Register( > Component.For<IService>().Instance(pS1).Named("sinst") ); > pContainer.Register( > Component.For<IService>().ImplementedBy<TestService>().LifeStyle.Transient > ); > > IService pS2 = pContainer.Resolve<IService>("sinst"); > IService pS3 = pContainer.Resolve<IService>(); > > Assert.AreEqual(pS1, pS2); > Assert.AreNotEqual(pS2, pS3); > > This test fails, because pS2 and pS3 are the same instance. Is this the > correct behaviour? How can i > solve this? > > Thanks > > -- > 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]<castle-project-users%[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.
