riteshrao/ncommon

bug in WindsorContainerAdapter

rikbosch opened this issue · 1 comments

The WindsorContainerAdapter contains a bug.

The method Register(Type service, Type implementation) does not contain a lifestyle definition for the registered component, which will result in Windsor's default lifestyle => singleton ( see http://docs.castleproject.org/Windsor.LifeStyles.ashx#Singleton_1)

The components should be registered with a transient lifestyle

It is possible to work around this; for example:

        Container = new WindsorContainer();

        Container.Kernel.ComponentModelCreated += new ComponentModelDelegate(Kernel_ComponentModelCreated);



    private void Kernel_ComponentModelCreated(Castle.Core.ComponentModel model)
    {
        if (model.LifestyleType == LifestyleType.Undefined)
        {

            model.LifestyleType = LifestyleType.Transient;
        }
    }