public static async Task InitializeAsync(UXXPackage package) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); OleMenuCommandService commandService = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService; IVsMonitorSelection monitorSelection = await package.GetServiceAsync(typeof(IVsMonitorSelection)) as IVsMonitorSelection; Instance = new Commands(package, monitorSelection, commandService); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); dte2 = await GetServiceAsync(typeof(SDTE)) as DTE2; Assumes.Present(dte2); InitializeAsync(); singleton = this; await Commands.InitializeAsync(this); }
private Commands(UXXPackage package, IVsMonitorSelection monitorSelection, OleMenuCommandService commandService) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var id = new CommandID(CommandSet, (int)PkgCmdIDList.cmdidCompile); var command = new OleMenuCommand(CompileCommandCallback, id); command.BeforeQueryStatus += CheckIsCompiling_BeforeQueryStatus; commandService.AddCommand(command); id = new CommandID(CommandSet, (int)PkgCmdIDList.cmdidCompileAll); command = new OleMenuCommand(CompileAllCommandCallback, id); command.BeforeQueryStatus += CheckIsCompiling_BeforeQueryStatus; commandService.AddCommand(command); id = new CommandID(CommandSet, (int)PkgCmdIDList.cmdidCompileError); command = new OleMenuCommand(ShowCompileErrorWindow, id); commandService.AddCommand(command); id = new CommandID(CommandSet, (int)PkgCmdIDList.cmdidOutput); command = new OleMenuCommand(ShowOutputWindow, id); commandService.AddCommand(command); }