/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(AsyncPackage package, ProjectApiUser projectApiUser) { // Switch to the main thread - the call to AddCommand in ProjectApiCommands's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; Instance = new ProjectApiCommands(package, commandService, projectApiUser); }
/// <summary> /// Initializes a new instance of the <see cref="ProjectApiCommands"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> /// <param name="commandService">Command service to add command to, not null.</param> private ProjectApiCommands(AsyncPackage package, OleMenuCommandService commandService, ProjectApiUser projectApiUser) { Requires.NotNull(package, nameof(package)); Requires.NotNull(commandService, nameof(commandService)); Requires.NotNull(projectApiUser, nameof(projectApiUser)); this.package = package; this.projectApiUser = projectApiUser; var solutionDetailsCommandId = new CommandID(CommandSet, SolutionDetailsCommandId); var solutionDetailsMenuItem = new MenuCommand(this.ExecuteGetSolutionDetails, solutionDetailsCommandId); var projectDetailsCommandId = new CommandID(CommandSet, ProjectDetailsCommandId); var projectDetailsMenuItem = new MenuCommand(this.ExecuteGetProjectDetails, projectDetailsCommandId); var projectReferencesCommandId = new CommandID(CommandSet, ProjectReferencesCommandId); var projectReferencesMenuItem = new MenuCommand(this.ExecuteGetProjectReferences, projectReferencesCommandId); commandService.AddCommand(solutionDetailsMenuItem); commandService.AddCommand(projectDetailsMenuItem); commandService.AddCommand(projectReferencesMenuItem); }