Merge pull request #49 from ericklombardo/master

Resolved issue SPRNET-1547
This commit is contained in:
Marko Lahma
2013-11-10 02:45:58 -08:00
3 changed files with 24 additions and 1 deletions

View File

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

View File

@@ -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()
{

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:context="http://www.springframework.net/context"
default-lazy-init="true">
default-lazy-init="true" default-autowire="byName">
<context:component-scan base-assemblies="Spring.Core.Tests">
<context:include-filter type="regex" expression="ComponentScan.ComponentsUseDefaults.*"/>