Beispiel #1
0
        internal override void OnKeyPreview(ref Key key)
        {
            bool checkedChanged = false;

            if (HasFocus && key == Key.Ok)
            {
                checkedChanged = true;
                IsChecked      = !IsChecked; // First toggle the state, then execute the base handler
            }

            base.OnKeyPreview(ref key);
            if (checkedChanged)
            {
                key = Key.None;
                if (IsChecked)
                {
                    IExecutableCommand cmd = Checked;
                    if (cmd != null)
                    {
                        InputManager.Instance.ExecuteCommand(cmd.Execute);
                    }
                }
                else
                {
                    IExecutableCommand cmd = Unchecked;
                    if (cmd != null)
                    {
                        InputManager.Instance.ExecuteCommand(cmd.Execute);
                    }
                }
            }
        }
 protected void CreateContext()
 {
     xenStore          = MockRepository.GenerateMock <IXenStore>();
     commandFactory    = MockRepository.GenerateMock <ICommandFactory>();
     executableCommand = MockRepository.GenerateMock <IExecutableCommand>();
     logger            = MockRepository.GenerateMock <ILogger>();
     commandQueue      = new CommandQueue(xenStore, commandFactory, logger);
 }
 protected void CreateContext()
 {
     xenStore = MockRepository.GenerateMock<IXenStore>();
     commandFactory = MockRepository.GenerateMock<ICommandFactory>();
     executableCommand = MockRepository.GenerateMock<IExecutableCommand>();
     logger = MockRepository.GenerateMock<ILogger>();
     commandQueue = new CommandQueue(xenStore, commandFactory, logger);
 }
        public override void Execute(UIElement element)
        {
            IExecutableCommand cmd = Command;

            if (cmd != null)
            {
                InputManager.Instance.ExecuteCommand(cmd.Execute);
            }
        }
Beispiel #5
0
        protected void Execute()
        {
            TrySetFocus(true);
            IsPressed = true;
            IExecutableCommand cmd = Command;

            if (cmd != null)
            {
                InputManager.Instance.ExecuteCommand(cmd.Execute);
            }
        }
        public EnqueueCommandMessage(object sender, IExecutableCommand command, bool transient = false) : base(sender)
        {
#if DEBUG
            // ReSharper disable once JoinNullCheckWithUsage
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
#endif
            ExecutableCommand = command;
            Transient         = transient;
        }
 public void Add(IChainableCommand command)
 {
     if (FirstCommand == null)
     {
         FirstCommand = command;
         lastCommand  = command;
     }
     else
     {
         lastCommand.SetSuccessor(command);
         lastCommand = command;
     }
 }
 public ExecutableResult Execute(IExecutableCommand commandExecutable, Command command)
 {
     runInSafeBlock(SvcConfiguration.PreHookPath(command.name));
     var result = commandExecutable.Execute(command.value);
     if (result.ExitCode == "0")
     {
         runInSafeBlock(SvcConfiguration.PostHookPath(command.name));
     }
     else
     {
         _logger.Log(string.Format("Bypassing post command hook, received an exit code of {0} from the command {1}", result.ExitCode, command.name));
     }
     return result;
 }
Beispiel #9
0
        protected bool Execute()
        {
            IExecutableCommand cmd = Command;

            if (!IsEnabled)
            {
                return(false);
            }
            if (cmd != null)
            {
                InputManager.Instance.ExecuteCommand(cmd.Execute);
            }
            return(true);
        }
Beispiel #10
0
 public bool TryExecuteCommand(IExecutableCommand query, out IEnumerable <string> errors)
 {
     using (var session = _sessionFactory.OpenSession())
         using (var tx = session.BeginTransaction())
         {
             if (!query.TryExecute(session, out errors))
             {
                 tx.Rollback();
                 return(false);
             }
             tx.Commit();
             return(Success(out errors));
         }
 }
Beispiel #11
0
        public ExecutableResult Execute(IExecutableCommand commandExecutable, Command command)
        {
            runInSafeBlock(SvcConfiguration.PreHookPath(command.name));
            var result = commandExecutable.Execute(command.value);

            if (result.ExitCode == "0")
            {
                runInSafeBlock(SvcConfiguration.PostHookPath(command.name));
            }
            else
            {
                _logger.Log(string.Format("Bypassing post command hook, received an exit code of {0} from the command {1}", result.ExitCode, command.name));
            }
            return(result);
        }
        public override void Execute(UIElement element)
        {
            IExecutableCommand cmd = Command;

            if (cmd == null)
            {
                return;
            }
            if (element.ElementState == ElementState.Running)
            {
                InputManager.Instance.ExecuteCommand(cmd.Execute);
            }
            else
            {
                cmd.Execute();
            }
        }
        public void Execute()
        {
            IList <object> convertedCommands = LateBoundValue.ConvertLateBoundValues(_commands);

            foreach (object objectCmd in convertedCommands)
            {
                object o;
                if (!TypeConverter.Convert(objectCmd, typeof(IExecutableCommand), out o))
                {
                    throw new ArgumentException(string.Format("CommandList: Command '{0}' cannot be converted to {1}", objectCmd, typeof(IExecutableCommand).Name));
                }
                IExecutableCommand cmd = (IExecutableCommand)o;
                cmd.Execute();
                if (!ReferenceEquals(cmd, objectCmd))
                {
                    MPF.TryCleanupAndDispose(cmd);
                }
            }
        }
 private static bool hasPrePostCommandAttribute(IExecutableCommand command)
 {
     return(command.GetType().GetCustomAttributes(typeof(PreAndPostCommandAttribute), true).Any());
 }
 void Init()
 {
     _command = null;
 }
 public static IChainableCommand AsChainableCommand(this IExecutableCommand command)
 {
     return(new ActionCommand(() => { command?.Execute(); return true; }));
 }
 public void SetSuccessor(IExecutableCommand successor)
 {
     this.Successor = successor;
 }
 void Init()
 {
   _command = null;
 }
Beispiel #19
0
 public IChainableCommand HandleExceptionCommand(Action <Exception> onExceptionAction = null, IExecutableCommand finallyCommand = null)
 {
     return(new HandleExceptionCommand(ex => onExceptionAction?.Invoke(ex), () => finallyCommand?.Execute()));
 }