riteshrao / ncommon

A framework for implementing commonly used design patterns when using Domain Driven Design
www.codeinsanity.com
218 stars 61 forks source link

bug in WindsorContainerAdapter #25

Closed rikbosch closed 12 years ago

rikbosch commented 13 years ago

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

dplaskon commented 13 years ago

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;
        }
    }