protected ILSpyCommand(SpyDefinitionPackage owner, uint id) { this.owner = owner; CommandID menuCommandID = new CommandID(CommandSet, (int)id); OleMenuCommand menuItem = new OleMenuCommand(OnExecute, menuCommandID); menuItem.BeforeQueryStatus += OnBeforeQueryStatus; OleMenuCommandService commandService = this.owner.GetServiceAsync(typeof(IMenuCommandService)).Result as OleMenuCommandService; if (commandService != null) { commandService.AddCommand(menuItem); } }
/// <summary> /// Initializes a new instance of the <see cref="ShowDefinitionInILSpyCommand"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> private ShowDefinitionInILSpyCommand(SpyDefinitionPackage package) : base(package, CommandId) { if (package == null) { throw new ArgumentNullException("package"); } this.package = package; //OleMenuCommandService commandService = // this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; //if (commandService != null) //{ // var menuCommandID = new CommandID(ILSpyCommand.CommandSet, CommandId); // var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID); // commandService.AddCommand(menuItem); //} _dte = Package.GetGlobalService(typeof(DTE)) as DTE; var componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel)); this.workspace = componentModel.GetService <VisualStudioWorkspace>() as VisualStudioWorkspace; }
/// <summary> /// Gets the service provider from the owner package. /// </summary> /// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static void Initialize(SpyDefinitionPackage package) { Instance = new ShowDefinitionInILSpyCommand(package); }