Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv32125/Support
Modified Files:
ManagedDictionary.cs ManagedList.cs ManagedSet.cs
Log Message:
PropertyPlaceholderConfigurer does not replace property values in <list element-type=${prop}> [SPRNET-719]
Index: ManagedList.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/ManagedList.cs,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ManagedList.cs 17 Aug 2007 02:43:30 -0000 1.14
--- ManagedList.cs 26 Nov 2007 14:15:54 -0000 1.15
***************
*** 30,33 ****
--- 30,34 ----
using Spring.Core;
using Spring.Core.TypeConversion;
+ using Spring.Core.TypeResolution;
using Spring.Util;
***************
*** 45,58 ****
public class ManagedList : ArrayList, IManagedCollection
{
! private Type elementType;
/// <summary>
! /// Gets or sets the type of the elements of this managed list.
/// </summary>
! /// <value>The type of the elements of this managed list.</value>
! public Type ElementType
{
! get { return this.elementType; }
! set { this.elementType = value; }
}
--- 46,60 ----
public class ManagedList : ArrayList, IManagedCollection
{
! private string elementTypeName;
/// <summary>
! /// Gets or sets the unresolved name for the <see cref="System.Type"/>
! /// of the elements of this managed list.
/// </summary>
! /// <value>The unresolved name for the type of the elements of this managed list.</value>
! public string ElementTypeName
{
! get { return this.elementTypeName; }
! set { this.elementTypeName = value; }
}
***************
*** 78,83 ****
{
IList list;
#if NET_2_0
! if (this.elementType == null)
{
list = new ArrayList();
--- 80,91 ----
{
IList list;
+
+ Type elementType = null;
+ if (StringUtils.HasText(this.elementTypeName))
+ {
+ elementType = TypeResolutionUtils.ResolveType(this.elementTypeName);
+ }
#if NET_2_0
! if (elementType == null)
{
list = new ArrayList();
***************
*** 87,91 ****
// CLOVER:ON
Type type = typeof(List<>);
! Type[] genericArgs = new Type[1] { this.elementType };
type = type.MakeGenericType(genericArgs);
--- 95,99 ----
// CLOVER:ON
Type type = typeof(List<>);
! Type[] genericArgs = new Type[1] { elementType };
type = type.MakeGenericType(genericArgs);
***************
*** 102,114 ****
resolver(objectName, definition, String.Format(CultureInfo.InvariantCulture, "{0}[{1}]", propertyName, i), element);
! if (this.elementType != null)
{
try
{
! resolvedElement = TypeConversionUtils.ConvertValueIfNecessary(this.elementType, resolvedElement, propertyName + "[" + i + "]");
}
catch (TypeMismatchException)
{
! ThrowTypeMismatchException(objectName, propertyName, resolvedElement);
}
}
--- 110,126 ----
resolver(objectName, definition, String.Format(CultureInfo.InvariantCulture, "{0}[{1}]", propertyName, i), element);
! if (elementType != null)
{
try
{
! resolvedElement = TypeConversionUtils.ConvertValueIfNecessary(elementType, resolvedElement, propertyName + "[" + i + "]");
}
catch (TypeMismatchException)
{
! throw new TypeMismatchException(
! String.Format(
! "Unable to convert managed list element '{0}' from [{1}] into [{2}] during initialization"
! + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?",
! resolvedElement, resolvedElement.GetType(), elementType, propertyName, objectName));
}
}
***************
*** 119,131 ****
return list;
}
-
- private void ThrowTypeMismatchException(string objectName, string propertyName, object resolvedElement)
- {
- throw new TypeMismatchException(
- String.Format(
- "Unable to convert managed list element '{0}' from [{1}] into [{2}] during initialization"
- + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?", resolvedElement,
- resolvedElement.GetType(), this.elementType, propertyName, objectName));
- }
}
}
\ No newline at end of file
--- 131,134 ----
Index: ManagedDictionary.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/ManagedDictionary.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ManagedDictionary.cs 17 Aug 2007 02:43:30 -0000 1.13
--- ManagedDictionary.cs 26 Nov 2007 14:15:54 -0000 1.14
***************
*** 31,34 ****
--- 31,35 ----
using Spring.Core;
using Spring.Core.TypeConversion;
+ using Spring.Core.TypeResolution;
using Spring.Util;
***************
*** 46,70 ****
public class ManagedDictionary : Hashtable, IManagedCollection
{
! private Type keyType;
! private Type valueType;
/// <summary>
! /// Gets or sets the type of the keys of this managed dictionary.
/// </summary>
! /// <value>The type of the keys of this managed dictionary.</value>
! public Type KeyType
{
! get { return this.keyType; }
! set { this.keyType = value; }
}
/// <summary>
! /// Gets or sets the type of the values of this managed dictionary.
/// </summary>
! /// <value>The type of the values of this managed dictionary.</value>
! public Type ValueType
{
! get { return this.valueType; }
! set { this.valueType = value; }
}
--- 47,73 ----
public class ManagedDictionary : Hashtable, IManagedCollection
{
! private string keyTypeName;
! private string valueTypeName;
/// <summary>
! /// Gets or sets the unresolved name for the <see cref="System.Type"/>
! /// of the keys of this managed dictionary.
/// </summary>
! /// <value>The unresolved name for the type of the keys of this managed dictionary.</value>
! public string KeyTypeName
{
! get { return this.keyTypeName; }
! set { this.keyTypeName = value; }
}
/// <summary>
! /// Gets or sets the unresolved name for the <see cref="System.Type"/>
! /// of the values of this managed dictionary.
/// </summary>
! /// <value>The unresolved name for the type of the values of this managed dictionary.</value>
! public string ValueTypeName
{
! get { return this.valueTypeName; }
! set { this.valueTypeName = value; }
}
***************
*** 91,99 ****
string propertyName, ManagedCollectionElementResolver resolver)
{
! IDictionary map;
#if NET_2_0
! if ((this.keyType == null) && (this.valueType == null))
{
! map = new HybridDictionary();
}
else
--- 94,114 ----
string propertyName, ManagedCollectionElementResolver resolver)
{
! IDictionary dictionary;
!
! Type keyType = null;
! if (StringUtils.HasText(this.keyTypeName))
! {
! keyType = TypeResolutionUtils.ResolveType(this.keyTypeName);
! }
!
! Type valueType = null;
! if (StringUtils.HasText(this.valueTypeName))
! {
! valueType = TypeResolutionUtils.ResolveType(this.valueTypeName);
! }
#if NET_2_0
! if ((keyType == null) && (valueType == null))
{
! dictionary = new HybridDictionary();
}
else
***************
*** 101,112 ****
Type type = typeof(Dictionary<,>);
Type[] genericArgs = new Type[2] {
! (this.keyType == null) ? typeof(object) : this.keyType,
! (this.valueType == null) ? typeof(object) : this.valueType };
type = type.MakeGenericType(genericArgs);
! map = (IDictionary)ObjectUtils.InstantiateType(type);
}
#else
! map = new HybridDictionary();
#endif
foreach (object key in this.Keys)
--- 116,127 ----
Type type = typeof(Dictionary<,>);
Type[] genericArgs = new Type[2] {
! (keyType == null) ? typeof(object) : keyType,
! (valueType == null) ? typeof(object) : valueType };
type = type.MakeGenericType(genericArgs);
! dictionary = (IDictionary)ObjectUtils.InstantiateType(type);
}
#else
! dictionary = new HybridDictionary();
#endif
foreach (object key in this.Keys)
***************
*** 114,166 ****
string elementName = string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", propertyName, key);
object resolvedKey = resolver(objectName, definition, elementName, key);
! object resolvedElement = resolver(objectName, definition, elementName, this[key]);
! if (this.keyType != null)
{
try
{
! resolvedKey = TypeConversionUtils.ConvertValueIfNecessary(this.keyType, resolvedKey, propertyName);
}
catch (TypeMismatchException)
{
! ThrowKeyTypeMismatchException(objectName, propertyName, resolvedElement);
}
}
! if (this.valueType != null)
{
try
{
! resolvedElement = TypeConversionUtils.ConvertValueIfNecessary(this.valueType, resolvedElement, propertyName + "[" + resolvedKey + "]");
}
catch (TypeMismatchException)
{
! ThrowValueTypeMismatchException(objectName, propertyName, resolvedElement);
}
}
-
- map.Add(resolvedKey, resolvedElement);
- }
- return map;
- }
! private void ThrowKeyTypeMismatchException(string objectName, string propertyName, object resolvedKey)
! {
! throw new TypeMismatchException(
! String.Format(
! "Unable to convert managed dictionary key '{0}' from [{1}] into [{2}] during initialization"
! + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?", resolvedKey,
! resolvedKey.GetType(), this.keyType, propertyName, objectName));
! }
! private void ThrowValueTypeMismatchException(string objectName, string propertyName, object resolvedValue)
! {
! throw new TypeMismatchException(
! String.Format(
! "Unable to convert managed dictionary value '{0}' from [{1}] into [{2}] during initialization"
! + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?", resolvedValue,
! resolvedValue.GetType(), this.valueType, propertyName, objectName));
! }
!
}
}
\ No newline at end of file
--- 129,171 ----
string elementName = string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", propertyName, key);
object resolvedKey = resolver(objectName, definition, elementName, key);
! object resolvedValue = resolver(objectName, definition, elementName, this[key]);
! if (keyType != null)
{
try
{
! resolvedKey = TypeConversionUtils.ConvertValueIfNecessary(keyType, resolvedKey, propertyName);
}
catch (TypeMismatchException)
{
! throw new TypeMismatchException(
! String.Format(
! "Unable to convert managed dictionary key '{0}' from [{1}] into [{2}] during initialization"
! + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?",
! resolvedKey, resolvedKey.GetType(), keyType, propertyName, objectName));
}
}
! if (valueType != null)
{
try
{
! resolvedValue = TypeConversionUtils.ConvertValueIfNecessary(valueType, resolvedValue, propertyName + "[" + resolvedKey + "]");
}
catch (TypeMismatchException)
{
! throw new TypeMismatchException(
! String.Format(
! "Unable to convert managed dictionary value '{0}' from [{1}] into [{2}] during initialization"
! + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?",
! resolvedValue, resolvedValue.GetType(), valueType, propertyName, objectName));
}
}
! dictionary.Add(resolvedKey, resolvedValue);
! }
! return dictionary;
! }
}
}
\ No newline at end of file
Index: ManagedSet.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/ManagedSet.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ManagedSet.cs 31 Jul 2007 18:16:50 -0000 1.13
--- ManagedSet.cs 26 Nov 2007 14:15:54 -0000 1.14
***************
*** 27,30 ****
--- 27,31 ----
using Spring.Core;
using Spring.Core.TypeConversion;
+ using Spring.Core.TypeResolution;
using Spring.Util;
***************
*** 41,54 ****
public class ManagedSet : HybridSet, IManagedCollection
{
! private Type elementType;
/// <summary>
! /// Gets or sets the type of the elements of this managed set.
/// </summary>
! /// <value>The type of the elements of this managed set.</value>
! public Type ElementType
{
! get { return this.elementType; }
! set { this.elementType = value; }
}
--- 42,56 ----
public class ManagedSet : HybridSet, IManagedCollection
{
! private string elementTypeName;
/// <summary>
! /// Gets or sets the unresolved name for the <see cref="System.Type"/>
! /// of the elements of this managed set.
/// </summary>
! /// <value>The unresolved name for the type of the elements of this managed set.</value>
! public string ElementTypeName
{
! get { return this.elementTypeName; }
! set { this.elementTypeName = value; }
}
***************
*** 74,77 ****
--- 76,86 ----
{
ISet set = new HybridSet();
+
+ Type elementType = null;
+ if (StringUtils.HasText(this.elementTypeName))
+ {
+ elementType = TypeResolutionUtils.ResolveType(this.elementTypeName);
+ }
+
string elementName = propertyName + "[(set-element)]";
foreach (object element in this)
***************
*** 79,91 ****
object resolvedElement = resolver(objectName, definition, elementName, element);
! if (this.elementType != null)
{
try
{
! resolvedElement = TypeConversionUtils.ConvertValueIfNecessary(this.elementType, resolvedElement, propertyName);
}
catch (TypeMismatchException)
{
! ThrowTypeMismatchException(objectName, propertyName, resolvedElement);
}
}
--- 88,104 ----
object resolvedElement = resolver(objectName, definition, elementName, element);
! if (elementType != null)
{
try
{
! resolvedElement = TypeConversionUtils.ConvertValueIfNecessary(elementType, resolvedElement, propertyName);
}
catch (TypeMismatchException)
{
! throw new TypeMismatchException(
! String.Format(
! "Unable to convert managed set element '{0}' from [{1}] into [{2}] during initialization"
! + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?",
! resolvedElement, resolvedElement.GetType(), elementType, propertyName, objectName));
}
}
***************
*** 93,106 ****
set.Add(resolvedElement);
}
- return set;
- }
! private void ThrowTypeMismatchException(string objectName, string propertyName, object resolvedElement)
! {
! throw new TypeMismatchException(
! String.Format(
! "Unable to convert managed set element '{0}' from [{1}] into [{2}] during initialization"
! + " of property '{3}' for object '{4}'. Do you have an appropriate type converter registered?", resolvedElement,
! resolvedElement.GetType(), this.elementType, propertyName, objectName));
}
}
--- 106,111 ----
set.Add(resolvedElement);
}
! return set;
}
}
|