SPRNET-1409
Applied 'patch' (modified iteration algorithm) and added unit test to confirm proper behavior remains intact moving forward.
This commit is contained in:
@@ -43,7 +43,7 @@ namespace Spring.Core
|
||||
/// <see cref="System.Type.EmptyTypes"/> array to the overloaded constructor.
|
||||
/// </p>
|
||||
/// </remarks>
|
||||
/// <author>Rick Evans</author>
|
||||
/// <author>Rick Evans</author>
|
||||
/// <author>Bruno Baia</author>
|
||||
public class MethodParametersCriteria : ICriteria
|
||||
{
|
||||
@@ -90,30 +90,30 @@ namespace Spring.Core
|
||||
/// by this instance; false if not or the supplied <paramref name="datum"/> is null.
|
||||
/// </returns>
|
||||
public bool IsSatisfied(object datum)
|
||||
{
|
||||
bool satisfied = false;
|
||||
MethodInfo method = datum as MethodInfo;
|
||||
if (method != null)
|
||||
{
|
||||
ParameterInfo[] parameterInfosBeingChecked = method.GetParameters();
|
||||
if (parameterInfosBeingChecked != null
|
||||
&& parameterInfosBeingChecked.Length == _parameters.Length)
|
||||
{
|
||||
satisfied = true;
|
||||
for (int i = 0; i < _parameters.Length; ++i)
|
||||
{
|
||||
foreach (ParameterInfo paramInfo in parameterInfosBeingChecked)
|
||||
{
|
||||
if (paramInfo.ParameterType == _parameters[i])
|
||||
{
|
||||
satisfied = true;
|
||||
continue;
|
||||
}
|
||||
satisfied = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
bool satisfied = false;
|
||||
MethodInfo method = datum as MethodInfo;
|
||||
if (method != null)
|
||||
{
|
||||
ParameterInfo[] parameterInfosBeingChecked = method.GetParameters();
|
||||
if (parameterInfosBeingChecked != null
|
||||
&& parameterInfosBeingChecked.Length == _parameters.Length)
|
||||
{
|
||||
satisfied = true;
|
||||
for (int i = 0; i < _parameters.Length; ++i)
|
||||
{
|
||||
if (parameterInfosBeingChecked[i].ParameterType == _parameters[i])
|
||||
{
|
||||
satisfied = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
satisfied = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return satisfied;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,15 @@ namespace Spring.Core
|
||||
Assert.IsTrue (criteria.IsSatisfied (method), "Was not satisified with a method that takes no parameters by default.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsNotSatisfiedWhenOnlyFinalParamMatches()
|
||||
{
|
||||
MethodParametersCriteria criteria = new MethodParametersCriteria(
|
||||
new Type[] { typeof(object), typeof(object), typeof(TestObject) });
|
||||
MethodInfo method = GetType().GetMethod("BoJangles");
|
||||
Assert.IsFalse(criteria.IsSatisfied(method), "Was satisified with a method that only matches on the final parameter.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsSatisfied ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user