/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(DaprDebuggerPackage package) { // Switch to the main thread - the call to AddCommand in StopDependencies's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; Instance = new StopDependencies(package, commandService); }
/// <summary> /// Initializes a new instance of the <see cref="AttachToAllDaprInstancesInSolution" /> 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 AttachToAllDaprInstancesInSolution(DaprDebuggerPackage package, OleMenuCommandService commandService) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandId = new CommandID(CommandSet, CommandId); _menuItem = new MenuCommand(Execute, menuCommandId); commandService.AddCommand(_menuItem); }
/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(DaprDebuggerPackage package) { // Switch to the main thread - the call to AddCommand in AttachToAllDaprInstancesInSolutions's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; var dte2 = await package.GetDTE2Async(); Instance = new DebugAllDaprInstancesInSolution(package, commandService, dte2); }
/// <summary> /// Initializes a new instance of the <see cref="StartDependencies" /> 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 StartDependencies(DaprDebuggerPackage package, OleMenuCommandService commandService) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandId = new CommandID(CommandSet, CommandId); _menuItem = new MenuCommand(Execute, menuCommandId); package.DaprDependencyManager.StartMenuItem = _menuItem; commandService.AddCommand(_menuItem); }
/// <summary> /// Initializes a new instance of the <see cref="DebugAllDaprInstancesInSolution" /> 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> /// <param name="dte2">A <see cref="DTE2" /> instance, not null.</param> private DebugAllDaprInstancesInSolution(DaprDebuggerPackage package, OleMenuCommandService commandService, DTE2 dte2) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandId = new CommandID(CommandSet, CommandId); _menuItem = new MenuCommand(Execute, menuCommandId); commandService.AddCommand(_menuItem); _dteEvents = dte2.Events.DTEEvents; _dteEvents.ModeChanged += lastMode => { _menuItem.Enabled = dte2.Mode == vsIDEMode.vsIDEModeDesign; if (dte2.Mode == vsIDEMode.vsIDEModeDesign && lastMode == vsIDEMode.vsIDEModeDebug) { KillProcesses(); } }; }