Exemplo n.º 1
0
        /// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        public static async Task InitializeAsync(KubernetesExtensionPackage package)
        {
            // Switch to the main thread - the call to AddCommand in DeleteDeployment's constructor requires
            // the UI thread.
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

            OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            Instance = new DeleteDeployment(package, commandService);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeleteDeployment"/> 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 DeleteDeployment(KubernetesExtensionPackage package, OleMenuCommandService commandService)
        {
            this._package  = package ?? throw new ArgumentNullException(nameof(package));
            commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

            _deployment = _package.GetService <IDeployment>();
            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = new OleMenuCommand(this.Execute, menuCommandID);

            menuItem.BeforeQueryStatus += new EventHandler(this.OnBeforeLoad);
            commandService.AddCommand(menuItem);
        }