private object[] GetParameters(IRoutedMessage message, IInteractionNode handlingNode, Exception exception) { var target = handlingNode.MessageHandler.Unwrap(); var callParameters = target.GetType().GetMethod(message.As <ActionMessage>().MethodName, BindingFlags.Instance | BindingFlags.Public).GetParameters(); var rescueParameters = _method.Info.GetParameters(); return(InvocationExtension.GetArguments(PrepareParameters(message.Parameters, exception), callParameters, rescueParameters)); }
private object[] GetParameters(IInvocation invocation, Exception ex) { var targetParams = invocation.MethodInvocationTarget.GetParameters(); var parameters = invocation.TargetType.GetMethod(_methodName).GetParameters(); var args = invocation.Arguments.Add(ex).ToArray(); return(InvocationExtension.GetArguments(args, targetParams, parameters)); }
public bool BeforeExecute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters) { var methodName = message.As <ActionMessage>().MethodName; var questionPresenter = ServiceLocator.Current.GetInstance <IQuestionPresenter>(); var param = parameters.Add(questionPresenter).ToArray(); var target = handlingNode.MessageHandler.Unwrap(); var targetParams = target.GetType().GetMethod(methodName).GetParameters(); //Prepare if (_prepareMethod.IsNotNull()) { var prepareParams = InvocationExtension.GetArguments(param, targetParams, _prepareMethod.Info.GetParameters()); var prepareResult = _prepareMethod.Invoke(target, prepareParams); if (prepareResult != null) { if (prepareResult is bool) { return((bool)prepareResult); } } } //Show ServiceLocator.Current.GetInstance <IWindowManager>().ShowDialog(questionPresenter); //Callback if (_callbackMethod.IsNull()) { return(questionPresenter.Answer == Answer.Yes); } var callbackParams = InvocationExtension.GetArguments(param, targetParams, _callbackMethod.Info.GetParameters()); var result = _callbackMethod.Invoke(target, callbackParams); if (_callbackMethod.Info.ReturnType == typeof(bool)) { return((bool)result); } return(true); }