diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs index ed118ea6..63e9fd50 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs @@ -1097,7 +1097,8 @@ namespace Spring.Objects.Factory.Support if (ContainsSingleton(objectName)) { return true; - } else if (ParentObjectFactory is IConfigurableFactoryObject) + } + else if (ParentObjectFactory is IConfigurableListableObjectFactory) { // No object definition found in this factory -> delegate to parent return diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs index 6e1d16c7..1c4fa4ce 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs @@ -1440,8 +1440,38 @@ namespace Spring.Objects.Factory Assert.AreSame(testObject, resultObject); } + [Test] + public void HierarchicalObjectFactoryChildParentResolution() + { + DefaultListableObjectFactory parent = new DefaultListableObjectFactory(); + DefaultListableObjectFactory child = new DefaultListableObjectFactory(parent); + parent.RegisterSingleton("parent", new Parent()); + child.RegisterObjectDefinition("child", new RootObjectDefinition(typeof (Child), AutoWiringMode.AutoDetect)); + Child c = (Child) child.GetObject("child"); + Assert.IsNotNull(c); + } + #region Helper Classes + public interface IParent + { + + } + + public class Parent : IParent + { + + } + + public interface IChild + { + + } + + public class Child : IChild + { + public Child(Parent parent) { } + } public class GoodDisposable : IDisposable { public static int DisposeCount = 0;