Doh, I didn't realize that! Tuna Toksöz Eternal sunshine of the open source mind.
http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Sun, May 24, 2009 at 5:49 PM, Krzysztof Koz'mic < [email protected]> wrote: > > This belongs to Castle *users* group. > > Please don't spam this group with this kind of questions. > > Krzysztof > > vdhant pisze: > > Hi guys > > The first 2 fail but the third one passes??? > > Cheers > > Anthony > > > > //TestCase 1 : Fails > > using (WindsorContainer container = new WindsorContainer()) > > { > > container.Register( > > Castle.MicroKernel.Registration.Component.For<IMyInterface>(). > > Named("Instance"). > > ImplementedBy<MyClass>(). > > LifeStyle.Transient, > > Castle.MicroKernel.Registration.Component.For<IMyInterface>(). > > ImplementedBy<MyClass>(). > > LifeStyle.Singleton > > ); > > > > var singleton = container.Resolve<IMyInterface>(); > > var singleton1 = container.Resolve<IMyInterface>(); > > > > var instance = container.Resolve<IMyInterface>("Instance"); > > var instance1 = container.Resolve<IMyInterface>("Instance"); > > > > Assert.AreSame(singleton, singleton1); > > Assert.AreNotSame(instance, instance1); > > } > > > > //TestCase 2 : Fails > > using (WindsorContainer container = new WindsorContainer()) > > { > > container.Register( > > Castle.MicroKernel.Registration.Component.For<IMyInterface>(). > > Named("Singleton"). > > ImplementedBy<MyClass>(). > > LifeStyle.Singleton, > > Castle.MicroKernel.Registration.Component.For<IMyInterface>(). > > ImplementedBy<MyClass>(). > > LifeStyle.Transient > > ); > > > > var singleton = container.Resolve<IMyInterface>("Singleton"); > > var singleton1 = container.Resolve<IMyInterface>("Singleton"); > > > > var instance = container.Resolve<IMyInterface>(); > > var instance1 = container.Resolve<IMyInterface>(); > > > > Assert.AreSame(singleton, singleton1); > > Assert.AreNotSame(instance, instance1); > > } > > > > //TestCase 3 : Passes > > using (WindsorContainer container = new WindsorContainer()) > > { > > container.Register( > > Castle.MicroKernel.Registration.Component.For<IMyInterface>(). > > Named("Singleton"). > > ImplementedBy<MyClass>(). > > LifeStyle.Singleton, > > Castle.MicroKernel.Registration.Component.For<IMyInterface>(). > > Named("Instance"). > > ImplementedBy<MyClass>(). > > LifeStyle.Transient > > ); > > > > var singleton = container.Resolve<IMyInterface>("Singleton"); > > var singleton1 = container.Resolve<IMyInterface>("Singleton"); > > > > var instance = container.Resolve<IMyInterface>("Instance"); > > var instance1 = container.Resolve<IMyInterface>("Instance"); > > > > Assert.AreSame(singleton, singleton1); > > Assert.AreNotSame(instance, instance1); > > } > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Development List" 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-devel?hl=en -~----------~----~----~----~------~----~------~--~---
