in src/Microsoft.Xaml.Behaviors/Core/CallMethodAction.cs [59:91]
protected override void Invoke(object parameter)
{
if (this.AssociatedObject != null)
{
MethodDescriptor methodDescriptor = this.FindBestMethod(parameter);
if (methodDescriptor != null)
{
ParameterInfo[] parameters = methodDescriptor.Parameters;
// todo jekelly: reconcile these restrictions with spec questions (see below)
if (parameters.Length == 0)
{
methodDescriptor.MethodInfo.Invoke(this.Target, null);
}
else if (parameters.Length == 2 && this.AssociatedObject != null && parameter != null)
{
if (parameters[0].ParameterType.IsAssignableFrom(this.AssociatedObject.GetType())
&& parameters[1].ParameterType.IsAssignableFrom(parameter.GetType()))
{
methodDescriptor.MethodInfo.Invoke(this.Target, new object[] { this.AssociatedObject, parameter });
}
}
}
else if (this.TargetObject != null)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
ExceptionStringTable.CallMethodActionValidMethodNotFoundExceptionMessage,
this.MethodName,
this.TargetObject.GetType().Name));
}
}
}