public void DetachInfoBar(IInfoBar currentInfoBar)
        {
            if (currentInfoBar == null)
            {
                throw new ArgumentNullException(nameof(currentInfoBar));
            }

            PrivateInfoBarWrapper wrapper = currentInfoBar as PrivateInfoBarWrapper;
            if (wrapper == null)
            {
                throw new ArgumentException(Strings.InvalidInfoBarInstance, nameof(currentInfoBar));
            }

            currentInfoBar.Close();

            IVsInfoBarHost host;
            if (TryGetInfoBarHost(wrapper.Frame, out host))
            {
                host.RemoveInfoBar(wrapper.InfoBarUIElement);
            }
        }
 void IInfoBarManager.DetachInfoBar(IInfoBar currentInfoBar)
 {
     Assert.IsTrue(this.attached.Values.Contains(currentInfoBar), "Info bar is not attached");
     this.attached.Remove(attached.Single(kv => kv.Value == currentInfoBar).Key);
 }
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="customInfoBarMessage">Optional. If provided than this will be the message that will appear in info bar, otherwise a standard one will appear instead</param>
        private void UpdateRequired(string customInfoBarMessage = null)
        {
            this.AssertOnUIThread();
            IInfoBarManager manager = this.host.GetMefService<IInfoBarManager>();
            if (manager == null)
            {
                Debug.Fail("Cannot find IInfoBarManager");
                return;
            }

            this.currentErrorWindowInfoBar = manager.AttachInfoBar(
                ErrorListToolWindowGuid,
                customInfoBarMessage ?? Strings.SonarLintInfoBarUnboundProjectsMessage,
                Strings.SonarLintInfoBarUpdateCommandText,
                KnownMonikers.RuleWarning);

            if (this.currentErrorWindowInfoBar == null)
            {
                this.OutputMessage(Strings.SonarLintFailedToAttachInfoBarToErrorList);
                Debug.Fail("Failed to add an info bar to the error list tool window");
            }
            else
            {
                TelemetryLoggerAccessor.GetLogger(this.host)?.ReportEvent(TelemetryEvent.ErrorListInfoBarShow);

                this.currentErrorWindowInfoBar.Closed += this.CurrentErrorWindowInfoBar_Closed;
                this.currentErrorWindowInfoBar.ButtonClick += this.CurrentErrorWindowInfoBar_ButtonClick;

                // Need to capture the current binding information since the user can change the binding
                // and running the Update should just no-op in that case.
                var solutionBinding = this.host.GetService<ISolutionBindingSerializer>();
                solutionBinding.AssertLocalServiceIsNotNull();

                this.infoBarBinding = solutionBinding.ReadSolutionBinding();
            }
        }
        private void ClearCurrentInfoBar()
        {
            this.CancelQualityProfileProcessing();

            this.infoBarBinding = null;
            this.currentErrorWindowInfoBarHandlingClick = false;
            if (this.currentErrorWindowInfoBar == null)
            {
                return;
            }

            this.currentErrorWindowInfoBar.Closed -= this.CurrentErrorWindowInfoBar_Closed;
            this.currentErrorWindowInfoBar.ButtonClick -= this.CurrentErrorWindowInfoBar_ButtonClick;

            IInfoBarManager manager = this.host.GetMefService<IInfoBarManager>();
            if (manager == null) // Could be null during shut down
            {
                return;
            }

            manager.DetachInfoBar(this.currentErrorWindowInfoBar);
            this.currentErrorWindowInfoBar = null;
        }