Пример #1
0
        /// <summary>
        /// Initializes a new instance of the command.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        protected VSCommandBase(AsyncPackage package, OleMenuCommandService commandService, int commandID, Guid?customCommandSet = null)
        {
            package.ThrowOnNull(nameof(package));
            commandService.ThrowOnNull(nameof(commandService));

            Package = package;
            Guid commandSet = customCommandSet ?? DefaultCommandSet;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(commandSet, commandID);
                var menuItem      = new OleMenuCommand(CommandCallback, menuCommandID)
                {
                    // This defers the visibility logic back to the VisibilityConstraints in the .vsct file
                    Supported = false
                };

                commandService.AddCommand(menuItem);
            }
        }