Ah...ok I have to use...LifeStyle.Is( LifestyleType.Transient )...then it
works. But it is a little confusing, that one could simply
write ...LifeStyle.Transient and
will get a different behaviour.
Am 11.09.2010 14:52 schrieb Belvasis <[email protected]>:
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().Instance(pS1).Named("sinst") );
pContainer.Register( Component.For().ImplementedBy().LifeStyle.Transient
);
IService pS2 = pContainer.Resolve("sinst");
IService pS3 = pContainer.Resolve();
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].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.