private void DynamicCommandCallback(object sender, EventArgs e) { var cmd = (OleMenuCommand)sender ?? throw new InvalidCastException($"Unable to cast {nameof(sender)} to {typeof(OleMenuCommand)}"); var document = (cmd.Properties[HistoryItemKey] as IClosedDocument) ?? NullDocument.Instance; var command = _reopenSomeDocumentsCommandFactory.CreateCommand(document); command.Execute(); LoggerContext.Current.Logger.Info($"VS Command: {nameof(DocumentsHistoryCommand)} was executed with {command.GetType()}"); }
private void HandleOperatons(IHistoryCommandFactory historyCommandFactory) { var selectedItems = _listView.SelectedItems.Cast <ClosedDocumentHistoryItem>() .Select(s => s.ClosedDocument); var command = historyCommandFactory.CreateCommand(selectedItems.ToArray()); command.Execute(); LoggerContext.Current.Logger.Info($"Command: {command.GetType()} from ToolWindow was executed"); }