Example #1
0
        /// <summary>
        /// Defines the method to be called when the command is invoked.
        /// </summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        public void Execute(object parameter)
        {
            _isExecuting = true;
            SetActionContext(parameter);

            _controller.InternalInvokeAction(_action, executeCompleted: () =>
            {
                _isExecuting = false;

                var view      = _action.View;
                var viewModel = _action.ViewModel;

                _action = Actionflow <TView, TViewModel> .New <T>(view, viewModel);
            });
        }
Example #2
0
        private IAction Invoke <T>(ActionContext actionContext, Action executeCompleted = null)
            where T : Actionflow <TView, TViewModel>, new()
        {
            T actionToRun = null;

            try
            {
                actionToRun = Actionflow <TView, TViewModel> .New <T>(_view, _viewModel, actionContext);
            }
            catch (Exception exception)
            {
                ExceptionHandler.Handle(exception, Resources.ErrorMessageAction);
            }

            return(Invoke(actionToRun, true, executeCompleted));
        }
Example #3
0
        public RoutedAction(TView view, TViewModel viewModel, params ActionContextEntry[] entries)
        {
            if (entries == null)
            {
                throw new ArgumentNullException("entries");
            }

            try
            {
                _action = Actionflow <TView, TViewModel> .New <T>(view, viewModel);

                _entries = entries.ToList();
                FindController(viewModel);
            }
            catch (Exception exception)
            {
                ExceptionHandler.Handle(exception, Resources.ErrorMessageAction);
            }

            if (_controller == null)
            {
                throw new ArgumentException(Resources.ActionControllerNotFound);
            }
        }
Example #4
0
 /// <summary>
 /// Creates a new Actionflow instance and sets the required data.
 /// </summary>
 /// <typeparam name="T">The type of action to create.</typeparam>
 /// <param name="entries">The entries.</param>
 /// <returns>
 /// A new actionflow instance.
 /// </returns>
 public T CreateAction <T>(params ActionContextEntry[] entries)
     where T : Actionflow <TView, TViewModel>, new()
 {
     return(Actionflow <TView, TViewModel> .New <T>(View, (TViewModel)this, entries));
 }
Example #5
0
 /// <summary>
 /// Creates a new Actionflow instance and sets the required data.
 /// </summary>
 /// <typeparam name="T">The type of action to create.</typeparam>
 /// <param name="actionContext">The action context.</param>
 /// <returns>A new actionflow instance.</returns>
 internal T CreateAction <T>(ActionContext actionContext = null)
     where T : Actionflow <TView, TViewModel>, new()
 {
     return(Actionflow <TView, TViewModel> .New <T>(View, (TViewModel)this, actionContext));
 }