protected override async Task <object> InitializeToolWindowAsync(Type toolWindowType, int id, CancellationToken cancellationToken) { await JoinableTaskFactory.SwitchToMainThreadAsync(); var dte = await GetServiceAsync(typeof(DTE)) as DTE2; Assumes.Present(dte); var dto = new CommandTableExplorerDTO(); var dteCommands = new List <EnvDTE.Command>(); foreach (EnvDTE.Command command in dte.Commands) { if (!string.IsNullOrEmpty(command.Name)) { dteCommands.Add(command); } } dto.DTE = dte; dto.DteCommands = dteCommands.OrderBy(c => c.Name).ToList(); var factory = new CommandTableFactory(); ICommandTable table = factory.CreateCommandTableFromHost(this, HostLoadType.FromRegisteredMenuDlls); dto.CommandTable = await table.GetCommands(); return(dto); }
private async Task PopulateCTMCommandsAsync() { CommandTableFactory factory = new CommandTableFactory(); ICommandTable commandTable = factory.CreateCommandTableFromHost(serviceProvider, CommandTable.HostLoadType.FromCTM); IEnumerable<CommandTable.Command> commands = await commandTable.GetCommands(); foreach (var command in commands) { commandIdToCTMCommandMap[new CommandId(command.ItemId.Guid, (int)command.ItemId.DWord)] = command; } }