Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv26076/Util
Modified Files:
ReflectionUtils.cs
Added Files:
AttributeUtils.cs ExtendedAttributeBuilder.cs
SafeAttributeUtils.cs
Log Message:
SPRNET-606 - Fix in .NET 2.0 for problems with attributes in proxy generation.
Index: ReflectionUtils.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/ReflectionUtils.cs,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** ReflectionUtils.cs 5 Oct 2007 17:06:01 -0000 1.51
--- ReflectionUtils.cs 11 Oct 2007 05:57:25 -0000 1.52
***************
*** 203,207 ****
}
! /// <summary>
/// From a given list of constructors, selects the constructor having an exact match on the given <paramref name="argValues"/>' types.
/// </summary>
--- 203,288 ----
}
! /// <summary>
! /// From a given list of methods, selects the method having an exact match on the given <paramref name="argValues"/>' types.
! /// </summary>
! /// <param name="methodTypeName">the type of method (used for exception reporting only)</param>
! /// <param name="methods">the list of methods to choose from</param>
! /// <param name="argValues">the arguments to the method</param>
! /// <returns>the method matching exactly the passed <paramref name="argValues"/>' types</returns>
! /// <exception cref="AmbiguousMatchException">
! /// If more than 1 matching methods are found in the <paramref name="methods"/> list.
! /// </exception>
! private static MethodBase GetMethodBaseByArgumentValues(string methodTypeName, MethodBase[] methods,
! object[] argValues)
! {
! MethodBase match = null;
! int matchCount = 0;
!
! foreach (MethodBase m in methods)
! {
! ParameterInfo[] parameters = m.GetParameters();
! bool isMatch = true;
! bool isExactMatch = true;
! object[] paramValues = argValues;
!
! try
! {
! if (parameters.Length > 0)
! {
! ParameterInfo lastParameter = parameters[parameters.Length - 1];
! if (lastParameter.GetCustomAttributes(typeof(ParamArrayAttribute), false).Length > 0)
! {
! paramValues =
! PackageParamArray(argValues, parameters.Length,
! lastParameter.ParameterType.GetElementType());
! }
! }
!
! for (int i = 0; i < parameters.Length; i++)
! {
! Type paramType = parameters[i].ParameterType;
! object paramValue = paramValues[i];
! if ((paramValue == null && paramType.IsValueType)
! || (paramValue != null && !paramType.IsAssignableFrom(paramValue.GetType())))
! {
! isMatch = false;
! break;
! }
! if (paramValue == null || paramType != paramValue.GetType())
! {
! isExactMatch = false;
! }
! }
! }
! catch (InvalidCastException)
! {
! isMatch = false;
! }
!
! if (isMatch)
! {
! if (isExactMatch)
! {
! return m;
! }
!
! matchCount++;
! if (matchCount == 1)
! {
! match = m;
! }
! else
! {
! throw new AmbiguousMatchException(
! string.Format("Ambiguous match for {0} '{1}' for the specified number and types of arguments.", methodTypeName,
! m.Name));
! }
! }
! }
!
! return match;
! }
!
! /// <summary>
/// From a given list of constructors, selects the constructor having an exact match on the given <paramref name="argValues"/>' types.
/// </summary>
***************
*** 218,303 ****
! /// <summary>
! /// From a given list of methods, selects the method having an exact match on the given <paramref name="argValues"/>' types.
! /// </summary>
! /// <param name="methodTypeName">the type of method (used for exception reporting only)</param>
! /// <param name="methods">the list of methods to choose from</param>
! /// <param name="argValues">the arguments to the method</param>
! /// <returns>the method matching exactly the passed <paramref name="argValues"/>' types</returns>
! /// <exception cref="AmbiguousMatchException">
! /// If more than 1 matching methods are found in the <paramref name="methods"/> list.
! /// </exception>
! private static MethodBase GetMethodBaseByArgumentValues(string methodTypeName, MethodBase[] methods,
! object[] argValues)
! {
! MethodBase match = null;
! int matchCount = 0;
!
! foreach (MethodBase m in methods)
! {
! ParameterInfo[] parameters = m.GetParameters();
! bool isMatch = true;
! bool isExactMatch = true;
! object[] paramValues = argValues;
!
! try
! {
! if (parameters.Length > 0)
! {
! ParameterInfo lastParameter = parameters[parameters.Length - 1];
! if (lastParameter.GetCustomAttributes(typeof(ParamArrayAttribute), false).Length > 0)
! {
! paramValues =
! PackageParamArray(argValues, parameters.Length,
! lastParameter.ParameterType.GetElementType());
! }
! }
!
! for (int i = 0; i < parameters.Length; i++)
! {
! Type paramType = parameters[i].ParameterType;
! object paramValue = paramValues[i];
! if ((paramValue == null && paramType.IsValueType)
! || (paramValue != null && !paramType.IsAssignableFrom(paramValue.GetType())))
! {
! isMatch = false;
! break;
! }
! if (paramValue == null || paramType != paramValue.GetType())
! {
! isExactMatch = false;
! }
! }
! }
! catch (InvalidCastException)
! {
! isMatch = false;
! }
!
! if (isMatch)
! {
! if (isExactMatch)
! {
! return m;
! }
!
! matchCount++;
! if (matchCount == 1)
! {
! match = m;
! }
! else
! {
! throw new AmbiguousMatchException(
! string.Format("Ambiguous match for {0} '{1}' for the specified number and types of arguments.", methodTypeName,
! m.Name));
! }
! }
! }
!
! return match;
! }
!
! /// <summary>
/// Packages arguments into argument list containing parameter array as a last argument.
/// </summary>
--- 299,303 ----
! /// <summary>
/// Packages arguments into argument list containing parameter array as a last argument.
/// </summary>
--- NEW FILE: AttributeUtils.cs ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: SafeAttributeUtils.cs ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: ExtendedAttributeBuilder.cs ---
(This appears to be a binary file; contents omitted.)
|