minor polishing
introduced ICustomValueReferenceHolder for better fluent configuration extensibility
This commit is contained in:
@@ -1068,7 +1068,7 @@ namespace Spring.Objects.Factory.Support
|
||||
protected virtual IObjectWrapper InstantiateUsingFactoryMethod(string name, RootObjectDefinition definition, object[] arguments)
|
||||
{
|
||||
ConstructorResolver constructorResolver =
|
||||
new ConstructorResolver(this, this, InstantiationStrategy);
|
||||
new ConstructorResolver(this, this, InstantiationStrategy, CreateValueResolver());
|
||||
return constructorResolver.InstantiateUsingFactoryMethod(name, definition, arguments);
|
||||
}
|
||||
|
||||
@@ -1097,7 +1097,7 @@ namespace Spring.Objects.Factory.Support
|
||||
protected IObjectWrapper AutowireConstructor(string name, RootObjectDefinition definition, ConstructorInfo[] ctors, object[] explicitArgs)
|
||||
{
|
||||
ConstructorResolver constructorResolver =
|
||||
new ConstructorResolver(this, this, InstantiationStrategy);
|
||||
new ConstructorResolver(this, this, InstantiationStrategy, CreateValueResolver());
|
||||
return constructorResolver.AutowireConstructor(name, definition, ctors, explicitArgs);
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace Spring.Objects.Factory.Support
|
||||
private readonly IAutowireCapableObjectFactory autowireFactory;
|
||||
|
||||
private readonly IInstantiationStrategy instantiationStrategy;
|
||||
private readonly ObjectDefinitionValueResolver valueResolver;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConstructorResolver"/> class for the given factory
|
||||
@@ -59,12 +60,14 @@ namespace Spring.Objects.Factory.Support
|
||||
/// <param name="objectFactory">The object factory to work with.</param>
|
||||
/// <param name="autowireFactory">The object factory as IAutowireCapableObjectFactory.</param>
|
||||
/// <param name="instantiationStrategy">The instantiation strategy for creating objects.</param>
|
||||
/// <param name="valueResolver">the resolver to resolve property value placeholders if any</param>
|
||||
public ConstructorResolver(AbstractObjectFactory objectFactory, IAutowireCapableObjectFactory autowireFactory,
|
||||
IInstantiationStrategy instantiationStrategy)
|
||||
IInstantiationStrategy instantiationStrategy, ObjectDefinitionValueResolver valueResolver)
|
||||
{
|
||||
this.objectFactory = objectFactory;
|
||||
this.autowireFactory = autowireFactory;
|
||||
this.instantiationStrategy = instantiationStrategy;
|
||||
this.valueResolver = valueResolver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -516,7 +519,7 @@ namespace Spring.Objects.Factory.Support
|
||||
ConstructorArgumentValues cargs,
|
||||
ConstructorArgumentValues resolvedValues)
|
||||
{
|
||||
ObjectDefinitionValueResolver valueResolver = new ObjectDefinitionValueResolver(objectFactory);
|
||||
// ObjectDefinitionValueResolver valueResolver = new ObjectDefinitionValueResolver(objectFactory);
|
||||
int minNrOfArgs = cargs.ArgumentCount;
|
||||
|
||||
foreach (DictionaryEntry entry in cargs.IndexedArgumentValues)
|
||||
|
||||
@@ -117,11 +117,18 @@ namespace Spring.Objects.Factory.Support
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="definition"></param>
|
||||
/// <param name="argumentName"></param>
|
||||
/// <param name="argumentValue"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="name">
|
||||
/// The name of the object that is having the value of one of its properties resolved.
|
||||
/// </param>
|
||||
/// <param name="definition">
|
||||
/// The definition of the named object.
|
||||
/// </param>
|
||||
/// <param name="argumentName">
|
||||
/// The name of the property the value of which is being resolved.
|
||||
/// </param>
|
||||
/// <param name="argumentValue">
|
||||
/// The value of the property that is being resolved.
|
||||
/// </param>
|
||||
private object ResolvePropertyValue(string name, IObjectDefinition definition, string argumentName, object argumentValue)
|
||||
{
|
||||
object resolvedValue = null;
|
||||
@@ -133,6 +140,10 @@ namespace Spring.Objects.Factory.Support
|
||||
{
|
||||
resolvedValue = argumentValue;
|
||||
}
|
||||
else if (argumentValue is ICustomValueReferenceHolder)
|
||||
{
|
||||
resolvedValue = ((ICustomValueReferenceHolder) argumentValue).Resolve(objectFactory, name, definition, argumentName, argumentValue);
|
||||
}
|
||||
else if (argumentValue is ObjectDefinitionHolder)
|
||||
{
|
||||
// contains an IObjectDefinition with name and aliases...
|
||||
|
||||
@@ -2070,6 +2070,11 @@
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Objects\Factory\Config\ICustomValueReferenceHolder.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Objects\Factory\Config\ConstructorArgumentValues.cs"
|
||||
SubType = "Code"
|
||||
|
||||
@@ -653,6 +653,7 @@
|
||||
<Compile Include="Objects\Factory\Config\CommandLineArgsVariableSource.cs" />
|
||||
<Compile Include="Objects\Factory\Config\ConfigSectionVariableSource.cs" />
|
||||
<Compile Include="Objects\Factory\Config\ConnectionStringsVariableSource.cs" />
|
||||
<Compile Include="Objects\Factory\Config\ICustomValueReferenceHolder.cs" />
|
||||
<Compile Include="Objects\Factory\Config\DelegateObjectFactoryConfigurer.cs" />
|
||||
<Compile Include="Objects\Factory\Config\DependencyDescriptor.cs" />
|
||||
<Compile Include="Objects\Factory\Config\DictionaryVariableSource.cs" />
|
||||
|
||||
@@ -665,6 +665,7 @@
|
||||
<Compile Include="Objects\Factory\Config\CommandLineArgsVariableSource.cs" />
|
||||
<Compile Include="Objects\Factory\Config\ConfigSectionVariableSource.cs" />
|
||||
<Compile Include="Objects\Factory\Config\ConnectionStringsVariableSource.cs" />
|
||||
<Compile Include="Objects\Factory\Config\ICustomValueReferenceHolder.cs" />
|
||||
<Compile Include="Objects\Factory\Config\DelegateObjectFactoryConfigurer.cs" />
|
||||
<Compile Include="Objects\Factory\Config\DependencyDescriptor.cs" />
|
||||
<Compile Include="Objects\Factory\Config\DictionaryVariableSource.cs" />
|
||||
|
||||
Reference in New Issue
Block a user