/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> /// <param name="commandService">The command service.</param> public static void Initialize(Shell.AsyncPackage package, Shell.OleMenuCommandService commandService) { if (Interlocked.CompareExchange(ref _isCommandInitialized, value: INITIALIZED, comparand: NOT_INITIALIZED) == NOT_INITIALIZED) { Instance = new SuppressDiagnosticInSuppressionFileCommand(package, commandService); } }
/// <summary> /// Initializes the singleton instance of the command. Internal method shich should be called only from UI thread. /// </summary> /// <param name="package">Owner package, not null.</param> /// <param name="oleCommandService">The OLE command service.</param> /// <returns/> internal static void Initialize(Shell.AsyncPackage package, Shell.OleMenuCommandService oleCommandService) { if (Interlocked.CompareExchange(ref _isCommandInitialized, value: INITIALIZED, comparand: NOT_INITIALIZED) == NOT_INITIALIZED) { Instance = new GoToDeclarationOrHandlerCommand(package, oleCommandService); } }
public static async Task InitializeAsync(Shell.AsyncPackage package) { await Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); Shell.OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as Shell.OleMenuCommandService; Instance = new OpenT4EditorSettingsCommand(package, commandService); }
private OpenT4EditorSettingsCommand(Shell.AsyncPackage package, Shell.OleMenuCommandService commandService) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandID = new CommandID(CommandSet, CommandId); var menuItem = new MenuCommand(this.Execute, menuCommandID); commandService.AddCommand(menuItem); }
/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(Microsoft.VisualStudio.Shell.AsyncPackage package) { // Switch to the main thread - the call to AddCommand in MenuContext's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); OleMenuCommandService commandService = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService; Instance = new MenuContext(package, commandService); }
/// <summary> /// Initializes a new instance of the <see cref="MenuContext"/> 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 MenuContext(Microsoft.VisualStudio.Shell.AsyncPackage package, OleMenuCommandService commandService) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandID = new CommandID(CommandSet, CommandId); var menuItem = new MenuCommand(this.Execute, menuCommandID); commandService.AddCommand(menuItem); _workSpace = WorkSpace.Instance; }
/// <summary> /// Initializes a new instance of the <see cref="GoToDeclarationOrHandlerCommand"/> 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">The command service.</param> private GoToDeclarationOrHandlerCommand(Shell.AsyncPackage package, Shell.OleMenuCommandService commandService) : base(package, commandService, GoToDeclarationCommandId) { }
/// <summary> /// Initializes a new instance of the <see cref="SuppressDiagnosticInSuppressionFileCommand"/> 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 SuppressDiagnosticInSuppressionFileCommand(Shell.AsyncPackage package, Shell.OleMenuCommandService commandService) : base(package, commandService, SuppressDiagnosticInSuppressionFileId) { }
protected SuppressDiagnosticCommandBase(Shell.AsyncPackage package, Shell.OleMenuCommandService commandService, int commandID) : base(package, commandService, commandID) { }