/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(Sql4CdsPackage package, DTE2 dte) { // Verify the current thread is the UI thread - the call to AddCommand in Sql2FetchXmlCommand's constructor requires // the UI thread. ThreadHelper.ThrowIfNotOnUIThread(); OleMenuCommandService commandService = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService; Instance = new Sql2MCommand(package, commandService, dte); }
/// <summary> /// Initializes a new instance of the <see cref="Sql2MCommand"/> 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 Sql2MCommand(Sql4CdsPackage package, OleMenuCommandService commandService, DTE2 dte) : base(package, dte) { commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandID = new CommandID(CommandSet, CommandId); var menuItem = new OleMenuCommand(this.Execute, menuCommandID); menuItem.BeforeQueryStatus += QueryStatus; commandService.AddCommand(menuItem); }
public DmlExecute(Sql4CdsPackage package, DTE2 dte) : base(package, dte) { _options = new Dictionary <TextDocument, QueryExecutionOptions>(); var execute = dte.Commands.Item("Query.Execute"); QueryExecuteEvent = dte.Events.CommandEvents[execute.Guid, execute.ID]; QueryExecuteEvent.BeforeExecute += OnExecuteQuery; var cancel = dte.Commands.Item("Query.CancelExecutingQuery"); QueryCancelEvent = dte.Events.CommandEvents[cancel.Guid, cancel.ID]; QueryCancelEvent.BeforeExecute += OnCancelQuery; }
public static void Initialize(Sql4CdsPackage package, DTE2 dte) { Instance = new DmlExecute(package, dte); }
protected CommandBase(Sql4CdsPackage package, DTE2 dte) { Package = package; Dte = dte; }