Ejemplo n.º 1
0
        public void Execute(object parameter)
        {
            if (!string.IsNullOrEmpty(CaliburnAction))
            {
                var methodName = CaliburnAction;
                if (methodName.EndsWith(""))
                {
                    methodName = methodName.Remove(methodName.Length - 2);
                }

                // will be overridden by Caliburn.
                var controls = MetaActionManager.Instance.GetControls(this);
                var source   = controls.First();

                var trigger = Parser.Parse(source, CaliburnAction).FirstOrDefault();
                var action  = trigger.Actions.OfType <ActionMessage>().FirstOrDefault();

                var context = new ActionExecutionContext
                {
                    EventArgs = new EventArgs(),
                    Message   = action,
                    Source    = source,
                };
                ActionMessage.PrepareContext(context);

                if (context.CanExecute == null || context.CanExecute())
                {
                    ActionMessage.InvokeAction(context);
                }
            }
        }
Ejemplo n.º 2
0
            protected override void Invoke(object parameter)
            {
                var context = new ActionExecutionContext
                {
                    Target  = _handler,
                    Message = new ActionMessage {
                        MethodName = "Execute"
                    },
                    Method = _handler.GetType().GetMethod("Execute")
                };

                ActionMessage.PrepareContext(context);

                if (context.CanExecute())
                {
                    ActionMessage.InvokeAction(context);
                }
            }
Ejemplo n.º 3
0
            protected override void Invoke(object parameter)
            {
                throw new NotImplementedException();
#warning Invoke
#if false
                var context = new ActionExecutionContext
                {
                    Target  = _handler,
                    Message = new ActionMessage {
                        MethodName = "Execute"
                    },
                    Method = _handler.GetType().GetMethod("Execute")
                };
                ActionMessage.PrepareContext(context);

                if (context.CanExecute())
                {
                    ActionMessage.InvokeAction(context);
                }
#endif
            }
 /// <summary>
 /// Defines the method that determines whether the command can execute in its current state.
 /// </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>
 /// <returns>true if this command can be executed; otherwise, false.</returns>
 public bool CanExecute(object parameter)
 {
     return(context.CanExecute == null || context.CanExecute());
 }