protected virtual RegisteredJumpAction PrepareJumpActionToRegister(IJumpAction jumpAction, string commandLineArgumentPrefix, Func <string> launcherPath)
        {
            RegisteredJumpAction registeredJumpAction = new RegisteredJumpAction(jumpAction);
            string exePath = jumpAction.ApplicationPath;
            string applicationArguments = jumpAction.Arguments ?? string.Empty;

            if (string.IsNullOrEmpty(exePath))
            {
                exePath = currentProcess.ExecutablePath;
            }
            if (string.Equals(exePath, currentProcess.ExecutablePath, StringComparison.OrdinalIgnoreCase))
            {
                string actionArg = commandLineArgumentPrefix + Uri.EscapeDataString(registeredJumpAction.Id);
                applicationArguments = string.IsNullOrEmpty(applicationArguments) ? actionArg : applicationArguments + actionArg;
            }
            string launcherArguments = string.Join(" ",
                                                   currentProcess.ApplicationId,
                                                   Uri.EscapeDataString(registeredJumpAction.Id),
                                                   Uri.EscapeDataString(exePath),
                                                   string.Format("\"{0}\"", Uri.EscapeDataString(applicationArguments))
                                                   );

            if (!string.IsNullOrEmpty(jumpAction.WorkingDirectory))
            {
                launcherArguments = string.Join(" ", launcherArguments, Uri.EscapeDataString(jumpAction.WorkingDirectory));
            }
            jumpAction.SetStartInfo(launcherPath(), launcherArguments);
            return(registeredJumpAction);
        }
        public void RegisterAction(IJumpAction jumpAction, string commandLineArgumentPrefix, Func <string> launcherPath)
        {
            if (!updating)
            {
                throw new InvalidOperationException();
            }
            Assert.IsNotNull(commandLineArgumentPrefix);
            Assert.IsNotNull(launcherPath);
            Assert.IsTrue(File.Exists(launcherPath()));
            Assert.IsNotNull(jumpAction.CommandId);
            ApplicationJumpTaskWrap applicationJumpTaskWrap = (ApplicationJumpTaskWrap)jumpAction;

            RegisteredActions.Add(applicationJumpTaskWrap.ApplicationJumpTask);
        }
        public void RegisterAction(IJumpAction jumpAction, string commandLineArgumentPrefix, Func <string> launcherPath)
        {
            Guard.ArgumentNotNull(jumpAction, "jumpAction");
            if (!updating)
            {
                throw new InvalidOperationException();
            }
            RegisterInstance();
            RegisteredJumpAction registeredjumpAction = PrepareJumpActionToRegister(jumpAction, commandLineArgumentPrefix, launcherPath);

            AddAction(registeredjumpAction);
            if (ShouldExecute(jumpAction.CommandId, commandLineArgumentPrefix))
            {
                ExecuteCore(jumpAction.CommandId);
            }
        }
        void ExecuteCore(string command)
        {
            RegisteredJumpAction registeredJumpAction;

            if (!jumpActions.TryGetValue(command, out registeredJumpAction))
            {
                return;
            }
            IJumpAction jumpAction = registeredJumpAction.GetJumpAction();

            if (jumpAction == null)
            {
                jumpActions.Remove(command);
            }
            else
            {
                registeredJumpAction.Dispatcher.BeginInvoke((Action)jumpAction.Execute);
            }
        }
 public RegisteredJumpAction(IJumpAction jumpAction)
 {
     Id            = jumpAction.CommandId;
     taskReference = new WeakReference(jumpAction);
     Dispatcher    = Dispatcher.CurrentDispatcher;
 }
 public void RegisterAction(IJumpAction jumpAction, string commandLineArgumentPrefix, Func<string> launcherPath) {
     if(!updating)
         throw new InvalidOperationException();
     Assert.IsNotNull(commandLineArgumentPrefix);
     Assert.IsNotNull(launcherPath);
     Assert.IsTrue(File.Exists(launcherPath()));
     Assert.IsNotNull(jumpAction.CommandId);
     ApplicationJumpTaskWrap applicationJumpTaskWrap = (ApplicationJumpTaskWrap)jumpAction;
     RegisteredActions.Add(applicationJumpTaskWrap.ApplicationJumpTask);
 }
 public RegisteredJumpAction(IJumpAction jumpAction) {
     Id = jumpAction.CommandId;
     taskReference = new WeakReference(jumpAction);
     Dispatcher = Dispatcher.CurrentDispatcher;
 }
 protected virtual RegisteredJumpAction PrepareJumpActionToRegister(IJumpAction jumpAction, string commandLineArgumentPrefix, Func<string> launcherPath) {
     RegisteredJumpAction registeredJumpAction = new RegisteredJumpAction(jumpAction);
     string exePath = jumpAction.ApplicationPath;
     string applicationArguments = jumpAction.Arguments ?? string.Empty;
     if(string.IsNullOrEmpty(exePath))
         exePath = currentProcess.ExecutablePath;
     if(string.Equals(exePath, currentProcess.ExecutablePath, StringComparison.OrdinalIgnoreCase)) {
         string actionArg = commandLineArgumentPrefix + Uri.EscapeDataString(registeredJumpAction.Id);
         applicationArguments = string.IsNullOrEmpty(applicationArguments) ? actionArg : applicationArguments + actionArg;
     }
     string launcherArguments = string.Join(" ",
         currentProcess.ApplicationId,
         Uri.EscapeDataString(registeredJumpAction.Id),
         Uri.EscapeDataString(exePath),
         string.Format("\"{0}\"", Uri.EscapeDataString(applicationArguments))
     );
     if(!string.IsNullOrEmpty(jumpAction.WorkingDirectory))
         launcherArguments = string.Join(" ", launcherArguments, Uri.EscapeDataString(jumpAction.WorkingDirectory));
     jumpAction.SetStartInfo(launcherPath(), launcherArguments);
     return registeredJumpAction;
 }
 public void RegisterAction(IJumpAction jumpAction, string commandLineArgumentPrefix, Func<string> launcherPath) {
     Guard.ArgumentNotNull(jumpAction, "jumpAction");
     if(!updating)
         throw new InvalidOperationException();
     RegisterInstance();
     RegisteredJumpAction registeredjumpAction = PrepareJumpActionToRegister(jumpAction, commandLineArgumentPrefix, launcherPath);
     AddAction(registeredjumpAction);
     if(ShouldExecute(jumpAction.CommandId, commandLineArgumentPrefix))
         ExecuteCore(jumpAction.CommandId);
 }