コード例 #1
0
        /// <summary>
        /// Initializes the instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        public static async Task InitializeAsync(AsyncPackage package)
        {
            // Switch to the main thread - the call to AddCommand in TunnelInspectorCommand's constructor requires
            // the UI thread.
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

            IProcessManagerService processManagerService = await package.GetServiceAsync(typeof(SProcessManagerService)) as IProcessManagerService;

            ITunnelManagerService tunnelManagerService = await package.GetServiceAsync(typeof(STunnelManagerService)) as ITunnelManagerService;

            if (processManagerService.StartedPriorToExtensionInit)
            {
                await tunnelManagerService.InitializeTunnelsAsync();
            }

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

            new TunnelInspectorCommand(package, commandService, processManagerService, tunnelManagerService);
        }
コード例 #2
0
        private async Task StartMonitorAsync()
        {
            await loggerService.WriteLineToOutputWindowAsync("Starting ngrok monitor...");

            if (!processManagerService.IsRunning)
            {
                if (webApplicationsManagerService.Projects.Count == 0)
                {
                    await loggerService.WriteLineToOutputWindowAsync("Did not find any web projects to monitor in this solution.  Shutting down.");

                    return;
                }

                var installPlease = false;

                if (!(await processManagerService.VerifyExecutableInstalledAsync()))
                {
                    await loggerService.WriteLineToOutputWindowAsync("not found");

                    if (AskUserYesNoQuestion("ngrok could not be located. Would you like me to download it from ngrok.com?"))
                    {
                        installPlease = true;
                    }
                    else
                    {
                        return;
                    }
                }

                if (installPlease)
                {
                    await loggerService.WriteToOutputWindowAsync("Attempting install...");

                    try
                    {
                        var installer = new NgrokInstaller();
                        var result    = await installer.InstallAsync();

                        if (result.Success)
                        {
                            await loggerService.WriteLineToOutputWindowAsync("successful.");

                            processManagerService.ExecutablePath = result.ExecutablePath;
                        }
                    }
                    catch (NgrokDownloadException ngrokDownloadException)
                    {
                        await loggerService.WriteLineToOutputWindowAsync("failed.");

                        await loggerService.WriteLineToOutputWindowAsync(ngrokDownloadException.Message);

                        return;
                    }
                }

                await processManagerService.StartAsync();
            }

            await tunnelManagerService.InitializeTunnelsAsync();

            //start websocket monitoring

            tunnelManagerService.IsMonitoring = true;
        }