/// <summary> /// Sites the instance of this class /// </summary> /// <param name="commandSet">The command set that holds this command</param> public virtual async void Site(IVsxCommandSet commandSet) { // --- Obtain and store command properties CommandSet = (TCommandSet)commandSet; Package = CommandSet.Package; var idAttr = GetType().GetTypeInfo().GetCustomAttribute <CommandIdAttribute>(); if (idAttr != null) { CommandId = idAttr.Value; } // --- Register the command await Package.JoinableTaskFactory.SwitchToMainThreadAsync(); var commandService = ((IServiceProvider)Package).GetService( typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService == null) { return; } var commandId = new CommandID(CommandSet.Guid, CommandId); OleMenuCommand = new OleMenuCommand((s, e) => { OnExecute(); }, commandId); OleMenuCommand.BeforeQueryStatus += (s, e) => { if (s is OleMenuCommand mc) { OnQueryStatus(mc); } }; commandService.AddCommand(OleMenuCommand); }
/// <summary> /// Sites the instance of this class /// </summary> /// <param name="commandSet">The command set that holds this command</param> public override void Site(IVsxCommandSet commandSet) { base.Site(commandSet); var twAttr = GetType().GetTypeInfo().GetCustomAttribute <ToolWindowAttribute>(); if (twAttr != null) { ToolWindowType = twAttr.Type; } }