/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static void Initialize(JsonButlerIdePackage package) { // Verify the current thread is the UI thread - the call to AddCommand in ConvertCamelCaseCommand's constructor requires // the UI thread. ThreadHelper.ThrowIfNotOnUIThread(); Instance = new ConvertCamelCaseCommand(package); }
/// <summary> /// Initializes a new instance of the <see cref="ConvertCamelCaseCommand"/> 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 ConvertCamelCaseCommand(JsonButlerIdePackage package) { _package = package ?? throw new ArgumentNullException(nameof(package)); if (!(ServiceProvider.GetService(typeof(IMenuCommandService)) is OleMenuCommandService commandService)) { throw new ArgumentNullException(nameof(commandService)); } CommandID menuCommandId = new CommandID(CommandSet, CommandId); MenuCommand menuItem = new MenuCommand(Execute, menuCommandId); commandService.AddCommand(menuItem); }