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); } }
void AddAction(RegisteredJumpAction jumpAction) { jumpActions[jumpAction.Id] = jumpAction; }
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; }