Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv30764
Modified Files:
ObjectDefinitionVisitor.cs
Log Message:
Fixed SPRNET-860 - Placeholders not resolved in name-values element.
Thanks ralfkret from the forum for the fix !
Index: ObjectDefinitionVisitor.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/ObjectDefinitionVisitor.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ObjectDefinitionVisitor.cs 26 Nov 2007 14:15:53 -0000 1.8
--- ObjectDefinitionVisitor.cs 18 Feb 2008 00:02:27 -0000 1.9
***************
*** 23,26 ****
--- 23,27 ----
using System;
using System.Collections;
+ using System.Collections.Specialized;
using Spring.Collections;
***************
*** 216,222 ****
VisitManagedDictionary((ManagedDictionary)value);
}
else if (value is TypedStringValue)
{
! TypedStringValue typedStringValue = (TypedStringValue) value;
String stringValue = typedStringValue.Value;
if (stringValue != null)
--- 217,227 ----
VisitManagedDictionary((ManagedDictionary)value);
}
+ else if (value is NameValueCollection)
+ {
+ VisitNameValueCollection((NameValueCollection)value);
+ }
else if (value is TypedStringValue)
{
! TypedStringValue typedStringValue = (TypedStringValue)value;
String stringValue = typedStringValue.Value;
if (stringValue != null)
***************
*** 232,238 ****
else if (value is ExpressionHolder)
{
! ExpressionHolder holder = (ExpressionHolder) value;
string newExpressionString = ResolveStringValue(holder.ExpressionString).ToString();
! return new ExpressionHolder(newExpressionString);
}
return value;
--- 237,243 ----
else if (value is ExpressionHolder)
{
! ExpressionHolder holder = (ExpressionHolder)value;
string newExpressionString = ResolveStringValue(holder.ExpressionString).ToString();
! return new ExpressionHolder(newExpressionString);
}
return value;
***************
*** 337,340 ****
--- 342,362 ----
/// <summary>
+ /// Visits the elements of a NameValueCollection and calls
+ /// <see cref="ResolveValue"/> for value of each element.
+ /// </summary>
+ protected virtual void VisitNameValueCollection(NameValueCollection collection)
+ {
+ foreach (string key in collection.AllKeys)
+ {
+ string oldValue = collection[key];
+ string newValue = ResolveValue(oldValue) as string;
+ if (!ObjectUtils.NullSafeEquals(newValue, oldValue))
+ {
+ collection[key] = newValue;
+ }
+ }
+ }
+
+ /// <summary>
/// Looks up the value of the given variable name in the configured <see cref="IVariableSource"/>.
/// </summary>
|