Sorry undefined lyfestyleType is set at registration time and never
changes (guess castle uses default typa which is singleton for such
components)


Here is the issue reproducing test

namespace Castle.Tests
{
    [TestFixture]
    public class CastleTests{

        public class Dependency : IDisposable
        {
            public Dependency()
            {
                Console.WriteLine("ctor: " + GetType().Name);
            }

            public void Dispose()
            {
                IsDisposed = true;
                Console.WriteLine("dispose: " + GetType().Name);
            }

            public bool IsDisposed { get; private set; }
        }


        public class Depender<T>
        {
            public T DependencyInstance { get; set; }

            public Depender(T d)
            {
                DependencyInstance = d;
            }
        }

        public interface IDependerFactory
        {
            Depender<T> CreateDepender<T>();
        }


        [Test]
        public void Test()
        {
            WindsorContainer container = new WindsorContainer();
            container.AddFacility<TypedFactoryFacility>();

            var assembly = Assembly.GetExecutingAssembly();
            container.Register(
                //Registering generic type
                AllTypes.FromAssembly(assembly).Where(o =>
o.Name.Contains("Depender")).
                    Configure(c => c.LifeStyle.Transient),
                Component.For<Dependency>().LifeStyle.Singleton,
                Component.For<IDependerFactory>().AsFactory()
                );

            var factory = container.Resolve<IDependerFactory>();
            Depender<Dependency> depender =
factory.CreateDepender<Dependency>();
            container.Dispose();

            Assert.IsTrue(depender.DependencyInstance.IsDisposed);
            Assert.AreEqual(0, container.Kernel.GraphNodes.Length);
        }
    }
}




On 26 ноя, 15:09, Konstantin <[email protected]> wrote:
> Unfortunately i failed to create a test reproducing the issue.
> Another strage thing: LifestyleType of not cleaned up components in
> GraphNodes  is changed from singleton to Undefined after container
> dispose.
>
> On 26 ноя, 01:31, Mauricio Scheffer <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > Can you submit a failing test reproducing the issue?
>
> > On Nov 25, 12:51 pm, Konstantin <[email protected]> wrote:
>
> > > I've noticed that not  all components implementing IDisposbale and
> > > having singleton lifycycle are disposed on container.Dispose() call.
> > > the _container.Kernel.GraphNodes property is also not empty after it.
> > > Some componentModels that are left in GraphNodes (looks like none of
> > > them is  disposed)  have Dependers that are not present on root level
> > > of GraphNodes.
>
> > > I"ve spent plenty of time investigating the problem and has no idea of
> > > what else can i check. Please help!

-- 
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.

Reply via email to