internal void TestConstructor(VerbosityLevel level) { var logger = new VerbosityLogger(level); logger.Level.Should().Be(level); }
private static void DoIt(IEnumerable <Bundle> bundles) { var verbosityLevel = CommandLineConfigs.CommandLineParseResult.CommandResult.GetVerbosityLevel(); var verbosityLogger = new VerbosityLogger(verbosityLevel); var canceled = false; using var cancelMutex = new Mutex(); var cancelProcessHandler = new ConsoleCancelEventHandler((sender, cancelArgs) => { cancelMutex.WaitOne(); try { if (!canceled) { canceled = true; Console.WriteLine(LocalizableStrings.CancelingMessage); } cancelArgs.Cancel = true; } finally { cancelMutex.ReleaseMutex(); } }); foreach (var bundle in bundles.ToList().AsReadOnly()) { verbosityLogger.Log(VerbosityLevel.Normal, string.Format(LocalizableStrings.UninstallNormalVerbosityFormat, bundle.DisplayName)); using var process = new Process { StartInfo = GetProcessStartInfo(bundle.UninstallCommand) }; Console.CancelKeyPress += cancelProcessHandler; if (!process.Start() || !process.WaitForExit(UNINSTALL_TIMEOUT)) { throw new UninstallationFailedException(bundle.UninstallCommand); } if (process.ExitCode != 0) { throw new UninstallationFailedException(bundle.UninstallCommand, process.ExitCode); } Console.CancelKeyPress -= cancelProcessHandler; cancelMutex.WaitOne(); try { if (canceled) { Environment.Exit(1); } } finally { cancelMutex.ReleaseMutex(); } } }