in src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Core/CallMethodAction.cs [80:127]
public object Execute(object sender, object parameter)
{
object target;
if (this.ReadLocalValue(CallMethodAction.TargetObjectProperty) != DependencyProperty.UnsetValue)
{
target = this.TargetObject;
}
else
{
target = sender;
}
if (target == null || string.IsNullOrEmpty(this.MethodName))
{
return false;
}
this.UpdateTargetType(target.GetType());
MethodDescriptor methodDescriptor = this.FindBestMethod(parameter);
if (methodDescriptor == null)
{
if (this.TargetObject != null)
{
throw new ArgumentException(string.Format(
CultureInfo.CurrentCulture,
ResourceHelper.CallMethodActionValidMethodNotFoundExceptionMessage,
this.MethodName,
this._targetObjectType));
}
return false;
}
ParameterInfo[] parameters = methodDescriptor.Parameters;
if (parameters.Length == 0)
{
methodDescriptor.MethodInfo.Invoke(target, parameters: null);
return true;
}
else if (parameters.Length == 2)
{
methodDescriptor.MethodInfo.Invoke(target, new object[] { target, parameter });
return true;
}
return false;
}