private async System.Threading.Tasks.Task InitAsync()
        {
            try
            {
                logger = await this.GetMefServiceAsync <ILogger>();

                logger.WriteLine(Resources.Strings.Daemon_Initializing);

                await DisableRuleCommand.InitializeAsync(this, logger);

                await CFamilyReproducerCommand.InitializeAsync(this, logger);

                cFamilyPreCompiledHeadersEventListener = await this.GetMefServiceAsync <IPreCompiledHeadersEventListener>();

                daemon = await this.GetMefServiceAsync <ISonarLintDaemon>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);

                // Set up the solution tracker so we can shut down the daemon when a solution is closed
                var solutionTracker = await this.GetMefServiceAsync <IActiveSolutionTracker>();

                solutionTracker.ActiveSolutionChanged += HandleActiveSolutionChanged;

                IDaemonInstaller installer = await this.GetMefServiceAsync <IDaemonInstaller>();

                if (!installer.IsInstalled())
                {
                    // Set up the status bar download handler in case the user enables
                    // support for additional languages during the VS session
                    var sbService = await this.GetServiceAsync(typeof(IVsStatusbar)) as IVsStatusbar;

                    statusBarDownloadProgressHandler = new StatusBarDownloadProgressHandler(sbService, installer, logger);

                    var settings = await this.GetMefServiceAsync <ISonarLintSettings>();

                    if (settings.IsActivateMoreEnabled)
                    {
                        // User already agreed to have the daemon installed so directly start download.
                        // No UI interation so we don't need to be on the UI thread.
                        installer.Install();
                    }
                }
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger?.WriteLine(Resources.Strings.ERROR_InitializingDaemon, ex);
            }
            logger?.WriteLine(Resources.Strings.Daemon_InitializationComplete);
        }
Ejemplo n.º 2
0
        private void OnActivateMoreClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!installer.IsInstalled())
                {
                    installer.Install();
                }

                settings.IsActivateMoreEnabled = true;

                UpdateActiveMoreControls();
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger.WriteLine(Strings.ERROR_ConfiguringDaemon, ex);
            }
        }
 public void Execute()
 {
     // Note: called on the UI thread so an unhandled exception will crash VS.
     // However, the only excecution path to this point should be from our tagger which
     // should handle any exceptions.
     if (!daemonInstaller.IsInstalled())
     {
         daemonInstaller.InstallationCompleted += HandleInstallCompleted;
         daemonInstaller.Install();
     }
     else
     {
         if (!daemon.IsRunning)
         {
             daemon.Ready += HandleDaemonReady;
             daemon.Start();
         }
         else
         {
             MakeRequest();
         }
     }
 }