Ejemplo n.º 1
0
        public static ValidationResult Validate(FrameworkElement element, string path, bool isOptional)
        {
            DirectoryMustExistsRule rule   = new DirectoryMustExistsRule(isOptional);
            ValidationResult        result = rule.Validate(path, CultureInfo.CurrentCulture);

            ValidationHelper.SetInvalid(element, result);
            return(result);
        }
Ejemplo n.º 2
0
        public bool Check()
        {
            if (!DirectoryMustExistsRule.Validate(GameDirectoryControl, GameDirectoryControl.Path, false).IsValid)
            {
                return(false);
            }
            if (!DirectoryMustExistsRule.Validate(WorkingDirectoryControl, WorkingDirectoryControl.Path, false).IsValid)
            {
                return(false);
            }
            if (!DirectoryMustExistsRule.Validate(CVSDirectoryControl, CVSDirectoryControl.Path, true).IsValid)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private ValidationResult ValidateGameDirectory()
        {
            try
            {
                string gameDirectoryPath = GameDirectoryControl.Path;

                ValidationResult result = DirectoryMustExistsRule.Validate(GameDirectoryControl, gameDirectoryPath, false);
                if (!result.IsValid)
                {
                    return(result);
                }

                string[] executables = Directory.GetFiles(gameDirectoryPath, Options.GameExecutableMask);
                if (executables.All(file => !Regex.IsMatch(file, Options.GameExecutablesExpression)))
                {
                    result = new ValidationResult(false, String.Format(Lang.ErrorFileNotFoundFormat, Options.GameExecutableMask));
                    ValidationHelper.SetInvalid(GameDirectoryControl, result);
                    return(result);
                }

                string dataDirectoryPath = Path.Combine(gameDirectoryPath, Options.GameDataDirectoryName);

                result = DirectoryMustExistsRule.Validate(GameDirectoryControl, dataDirectoryPath, false);
                if (!result.IsValid)
                {
                    return(result);
                }

                FileMustExistsRule fileMustExistsRule = new FileMustExistsRule(false);

                foreach (string archiveName in Options.GameArchivesNames)
                {
                    string archivePath = Path.Combine(dataDirectoryPath, archiveName);

                    result = fileMustExistsRule.Validate(Path.ChangeExtension(archivePath, ".fs"), CultureInfo.CurrentCulture);
                    if (!result.IsValid)
                    {
                        break;
                    }

                    result = fileMustExistsRule.Validate(Path.ChangeExtension(archivePath, ".fi"), CultureInfo.CurrentCulture);
                    if (!result.IsValid)
                    {
                        break;
                    }

                    result = fileMustExistsRule.Validate(Path.ChangeExtension(archivePath, ".fl"), CultureInfo.CurrentCulture);
                    if (!result.IsValid)
                    {
                        break;
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                ValidationResult result = new ValidationResult(false, ex.GetBaseException().Message);
                ValidationHelper.SetInvalid(GameDirectoryControl, result);
                return(result);
            }
        }
Ejemplo n.º 4
0
 private ValidationResult ValidateCVSDirectory()
 {
     return(DirectoryMustExistsRule.Validate(CVSDirectoryControl, CVSDirectoryControl.Path, true));
 }
Ejemplo n.º 5
0
 private ValidationResult ValidateWorkingDirectory()
 {
     return(DirectoryMustExistsRule.Validate(WorkingDirectoryControl, WorkingDirectoryControl.Path, false));
 }