コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }