protected override void Initialize()
        {
            AddOptionKey(NotificationDataKey);
            base.Initialize();

            var sonarqubeService = this.GetMefService <ISonarQubeService>();

            notifications = new SonarQubeNotificationService(sonarqubeService,
                                                             new NotificationIndicatorViewModel(), new TimerWrapper {
                Interval = 60000
            }, output);

            activeSolutionBoundTracker = this.GetMefService <IActiveSolutionBoundTracker>();
            activeSolutionBoundTracker.SolutionBindingChanged += OnSolutionBindingChanged;
        }
Esempio n. 2
0
        private async System.Threading.Tasks.Task InitAsync()
        {
            // Working on background thread...
            Debug.Assert(!ThreadHelper.CheckAccess());

            var sonarqubeService = await this.GetMefServiceAsync <ISonarQubeService>();

            logger = await this.GetMefServiceAsync <ILogger>();

            logger.WriteLine(Resources.Strings.Notifications_Initializing);

            AddOptionKey(NotificationDataKey);

            var telemetryManager = await this.GetMefServiceAsync <IServerNotificationsTelemetryManager>();

            var vsBrowserService = await this.GetMefServiceAsync <IVsBrowserService>();

            notifications = new SonarQubeNotificationService(sonarqubeService,
                                                             new NotificationIndicatorViewModel(telemetryManager, vsBrowserService), new TimerWrapper {
                Interval = 60000
            }, logger);

            // Initialising the UI elements has to be on the main thread
            await JoinableTaskFactory.SwitchToMainThreadAsync();

            SafePerformOpOnUIThread(() =>
            {
                // Creating the tracker might indirectly cause UI-related MEF components to be
                // created, so this needs to be done on the UI thread just in case.
                activeSolutionBoundTracker = this.GetMefService <IActiveSolutionBoundTracker>();

                // A bound solution might already have completed loading. If so, we need to
                // trigger the load of the options from the solution file
                if (activeSolutionBoundTracker.CurrentConfiguration.Mode != SonarLintMode.Standalone)
                {
                    var solutionPersistence = (IVsSolutionPersistence)this.GetService(typeof(SVsSolutionPersistence));
                    solutionPersistence.LoadPackageUserOpts(this, NotificationDataKey);
                }

                PerformUIInitialisation();
                logger.WriteLine(Resources.Strings.Notifications_InitializationComplete);
            });
        }