in src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Core/CallMethodAction.cs [129:155]
private MethodDescriptor FindBestMethod(object parameter)
{
TypeInfo parameterTypeInfo = parameter == null ? null : parameter.GetType().GetTypeInfo();
if (parameterTypeInfo == null)
{
return this._cachedMethodDescriptor;
}
MethodDescriptor mostDerivedMethod = null;
// Loop over the methods looking for the one whose type is closest to the type of the given parameter.
foreach (MethodDescriptor currentMethod in this._methodDescriptors)
{
TypeInfo currentTypeInfo = currentMethod.SecondParameterTypeInfo;
if (currentTypeInfo.IsAssignableFrom(parameterTypeInfo))
{
if (mostDerivedMethod == null || !currentTypeInfo.IsAssignableFrom(mostDerivedMethod.SecondParameterTypeInfo))
{
mostDerivedMethod = currentMethod;
}
}
}
return mostDerivedMethod ?? this._cachedMethodDescriptor;
}