public virtual void UnregisterPrig(PrigPackageViewModel vm) { var umwPkg = new MachineWideUninstallation(Resources.NuGetRootPackageVersion); umwPkg.Preparing += () => vm.BeginMachineWideProcessProgress(MachineWideProcesses.Uninstalling); umwPkg.ProfilerStatusChecking += profLoc => vm.ReportProfilerStatusCheckingProgress(10u, profLoc); umwPkg.DefaultSourceUninstalling += pkgName => vm.ReportDefaultSourceProcessingProgress(20u, pkgName, null); umwPkg.DefaultSourceUninstalled += stdout => vm.ReportDefaultSourceProcessedProgress(30u, stdout); umwPkg.ProfilerUnregistering += profLoc => vm.ReportProfilerProcessingProgress(40u, profLoc); umwPkg.ProfilerUnregistered += stdout => vm.ReportProfilerProcessedProgress(50u, stdout); umwPkg.EnvironmentVariableUnregistering += name => vm.ReportEnvironmentVariableProcessingProgress(60u, name, null); umwPkg.EnvironmentVariableUnregistered += name => vm.ReportEnvironmentVariableProcessedProgress(70u); umwPkg.NuGetSourceUnregistering += name => vm.ReportNuGetSourceProcessingProgress(80u, name, null); umwPkg.NuGetSourceUnregistered += stdout => vm.ReportNuGetSourceProcessedProgress(90u, stdout); umwPkg.Completed += result => { switch (result) { case MachineWideProcessResults.Skipped: vm.ShowSkippedMachineWideProcessMessage(SkippedReasons.AlreadyRegistered); vm.EndSkippedMachineWideProcessProgress(SkippedReasons.AlreadyRegistered); break; case MachineWideProcessResults.Completed: var restarts = vm.ConfirmRestartingVisualStudioToTakeEffect(); vm.EndCompletedMachineWideProcessProgress(); if (!restarts) return; ProcessMixin.RestartCurrentProcess(); break; } }; MachineWideInstaller.Uninstall(umwPkg); }
public virtual void PrepareUnregisteringPrig(PrigPackageViewModel vm) { vm.BeginMachineWideProcessProgress(MachineWideProcesses.Uninstalling); var machinePreq = new MachinePrerequisite(Resources.NuGetRootPackageVersion); machinePreq.ProfilerStatusChecking += profLoc => vm.ReportProfilerStatusCheckingProgress(50u, profLoc); if (!MachineWideInstaller.HasBeenInstalled(machinePreq)) { vm.ShowSkippedMachineWideProcessMessage(SkippedReasons.AlreadyRegistered); vm.EndSkippedMachineWideProcessProgress(SkippedReasons.AlreadyRegistered); return; } if (!WindowsIdentity.GetCurrent().IsElevated()) { vm.ShowVisualStudioHasNotBeenElevatedYetMessage(); if (ProcessMixin.RestartCurrentProcessWith(_ => { _.Verb = "runas"; })) return; vm.EndSkippedMachineWideProcessProgress(SkippedReasons.CanceledByUser); } else { UnregisterPrig(vm); } }
void RegisterPrig(PrigPackageViewModel vm) { var mwInstl = new MachineWideInstallation(Resources.NuGetRootPackageVersion); mwInstl.Preparing += () => vm.BeginMachineWideProcessProgress(MachineWideProcesses.Installing); mwInstl.ProfilerStatusChecking += profLoc => vm.ReportProfilerStatusCheckingProgress(8u, profLoc); mwInstl.NuGetPackageCreating += pkgName => vm.ReportNuGetPackageCreatingProgress(17u, pkgName); mwInstl.NuGetPackageCreated += stdout => vm.ReportNuGetPackageCreatedProgress(25u, stdout); mwInstl.NuGetSourceRegistering += (path, name) => vm.ReportNuGetSourceProcessingProgress(33u, path, name); mwInstl.NuGetSourceRegistered += stdout => vm.ReportNuGetSourceProcessedProgress(42u, stdout); mwInstl.EnvironmentVariableRegistering += (name, value) => vm.ReportEnvironmentVariableProcessingProgress(50u, name, value); mwInstl.EnvironmentVariableRegistered += (name, value) => vm.ReportEnvironmentVariableProcessedProgress(58u); mwInstl.ProfilerRegistering += profLoc => vm.ReportProfilerProcessingProgress(67u, profLoc); mwInstl.ProfilerRegistered += stdout => vm.ReportProfilerProcessedProgress(75u, stdout); mwInstl.DefaultSourceInstalling += (pkgName, src) => vm.ReportDefaultSourceProcessingProgress(83u, pkgName, src); mwInstl.DefaultSourceInstalled += stdout => vm.ReportDefaultSourceProcessedProgress(92u, stdout); mwInstl.Completed += result => { switch (result) { case MachineWideProcessResults.Skipped: vm.ShowSkippedMachineWideProcessMessage(SkippedReasons.AlreadyRegistered); vm.EndSkippedMachineWideProcessProgress(SkippedReasons.AlreadyRegistered); break; case MachineWideProcessResults.Completed: var restarts = vm.ConfirmRestartingVisualStudioToTakeEffect(); vm.EndCompletedMachineWideProcessProgress(); if (!restarts) return; ProcessMixin.RestartCurrentProcess(); break; } }; MachineWideInstaller.Install(mwInstl); }
public void EndSkippedMachineWideProcessProgress_should_report_the_progress_to_statusbar( [Values(MachineWideProcesses.Installing, MachineWideProcesses.Uninstalling)] MachineWideProcesses mwProc, [Values(SkippedReasons.AlreadyRegistered, SkippedReasons.CanceledByUser)] SkippedReasons reason) { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var vm = new PrigPackageViewModel(); vm.BeginMachineWideProcessProgress(mwProc); // Act vm.EndSkippedMachineWideProcessProgress(reason); // Assert var progState = vm.Statusbar.ProgressState.Value; Assert.AreEqual(0u, progState.Value); Assert.IsNullOrEmpty(progState.Label); Assert.IsNotNullOrEmpty(vm.Statusbar.Text.Value); }