diff --git a/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs b/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs index a988bca7..abd823d5 100644 --- a/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs +++ b/src/Spring/Spring.Core/Context/Attributes/ScannedGenericObjectDefinition.cs @@ -23,6 +23,7 @@ using System; using Common.Logging; using Spring.Objects; +using Spring.Objects.Factory.Config; using Spring.Objects.Factory.Support; using Spring.Objects.Factory.Xml; using Spring.Stereotype; @@ -78,8 +79,21 @@ namespace Spring.Context.Attributes bool lazyInit = false; bool.TryParse(defaults.LazyInit, out lazyInit); IsLazyInit = lazyInit; + + if (!String.IsNullOrEmpty(defaults.Autowire)) + { + AutowireMode = GetAutowireMode(defaults.Autowire); + } } + private AutoWiringMode GetAutowireMode(string value) + { + AutoWiringMode autoWiringMode; + autoWiringMode = (AutoWiringMode)Enum.Parse(typeof(AutoWiringMode), value, true); + return autoWiringMode; + } + + private void ParseScopeAttribute() { var attr = Attribute.GetCustomAttribute(ObjectType, typeof(ScopeAttribute), true) as ScopeAttribute; diff --git a/test/Spring/Spring.Core.Tests/Context/Config/ComponentScanObjectDefinitionParserTests.cs b/test/Spring/Spring.Core.Tests/Context/Config/ComponentScanObjectDefinitionParserTests.cs index 86ae53dd..f17b4b28 100644 --- a/test/Spring/Spring.Core.Tests/Context/Config/ComponentScanObjectDefinitionParserTests.cs +++ b/test/Spring/Spring.Core.Tests/Context/Config/ComponentScanObjectDefinitionParserTests.cs @@ -119,6 +119,15 @@ namespace Spring.Context.Config Assert.That(prototypeDef.IsLazyInit, Is.True); } + [Test] + public void ComponentsUseDefaultAutoWire() + { + _applicationContext = new XmlApplicationContext(ReadOnlyXmlTestResource.GetFilePath("ConfigFiles.ComponentScan5.xml", GetType())); + var prototypeDef = _applicationContext.ObjectFactory.GetObjectDefinition("Prototype"); + + Assert.That(prototypeDef.AutowireMode == AutoWiringMode.ByName); + } + [Test] public void ComponentWithQualifier() { diff --git a/test/Spring/Spring.Core.Tests/Context/Config/ConfigFiles/ComponentScan5.xml b/test/Spring/Spring.Core.Tests/Context/Config/ConfigFiles/ComponentScan5.xml index 85eb51a7..30b6dbe4 100644 --- a/test/Spring/Spring.Core.Tests/Context/Config/ConfigFiles/ComponentScan5.xml +++ b/test/Spring/Spring.Core.Tests/Context/Config/ConfigFiles/ComponentScan5.xml @@ -1,7 +1,7 @@  + default-lazy-init="true" default-autowire="byName">