コード例 #1
0
        public SaveBackupResult Save(string system, string user)
        {
            switch (_questionToBackup.Ask())
            {
            case QuestionToBackupResult.NoThanks:
                return(SaveBackupResult.Done);

            case QuestionToBackupResult.YesIWantBackup:
                return(_backup.Save(system, user));

            case QuestionToBackupResult.Cancel:
                return(SaveBackupResult.Cancel);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
        private void Save(object o)
        {
            if (o is IFormattedEnvironmentVariablePath formatted)
            {
                switch (_backup.Save(_environmentVariablePath.System, _environmentVariablePath.User))
                {
                case SaveBackupResult.Done:
                    break;

                case SaveBackupResult.Cancel:
                    throw new InvalidOperationException("Backup is canceled.");

                default:
                    throw new ArgumentOutOfRangeException();
                }
                if (_user.IsAdministrator)
                {
                    _environmentVariablePath.System = ParsePath(formatted.System);
                }
                _environmentVariablePath.User = ParsePath(formatted.User);
            }
        }