Пример #1
0
        /// <summary>
        /// Performs mod structure validation, XML and XSD validation, resource validation and expansion requirement validation.
        /// </summary>
        /// <returns></returns>
        public ModValidationResult Validate()
        {
            ModValidationResult result = new ModValidationResult();

            var modFolder = mod.GetDirectory(@"mod");

            if (modFolder == null)
            {
                result.ModErrors.Add("The required folder, 'mod', was not found.");
                return(result);
            }

            var modFile = modFolder.GetFile("mod.xml");

            if (modFile == null)
            {
                result.ModErrors.Add("The required file, 'mod/mod.xml', was not found.");
                return(result);
            }

            var xmlFiles = modFolder.EnumerateXmlFiles(DredmorInfo.XmlFilesToValidate, SearchOption.TopDirectoryOnly);

            XsdValidator xsd = new XsdValidator();

            result.XmlErrors = xsd.Validate(xmlFiles, true);

            if (!result.IsValid && result.XmlErrors.Any(p => p.XmlExceptionOccurred))
            {
                return(result);
            }

            resources.LoadResources(mod);

            result.XmlErrors.AddRange(
                XmlResourceValidator.Validate(
                    xmlFiles.Where(p => p.Name.ToLower() != "mod.xml"),
                    resources,
                    ExpansionResourcesUsed
                    )
                .Where(p => p.Errors.Count > 0)
                );

            result.ExpansionResourcedUsed = ExpansionResourcesUsed;

            result.ExpansionNumbersUsed =
                ExpansionResourcesUsed.Animations.Select(p => p.ExpansionNumber)
                .Concat(result.ExpansionResourcedUsed.Files.Select(p => p.ExpansionNumber))
                .Concat(result.ExpansionResourcedUsed.ContentResources.Select(p => p.ExpansionNumber))
                .Distinct()
                .OrderBy(p => p)
                .ToList();

            AddRequirementErrors(result, modFile);

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Performs mod structure validation, XML and XSD validation, resource validation and expansion requirement validation.
        /// </summary>
        /// <returns></returns>
        public ModValidationResult Validate()
        {
            ModValidationResult result = new ModValidationResult();

            var modFolder = mod.GetDirectory( @"mod" );

            if ( modFolder == null )
            {
                result.ModErrors.Add( "The required folder, 'mod', was not found." );
                return result;
            }

            var modFile = modFolder.GetFile( "mod.xml" );

            if ( modFile == null )
            {
                result.ModErrors.Add( "The required file, 'mod/mod.xml', was not found." );
                return result;
            }

            var xmlFiles = modFolder.EnumerateXmlFiles( DredmorInfo.XmlFilesToValidate, SearchOption.TopDirectoryOnly );

            XsdValidator xsd = new XsdValidator();
            result.XmlErrors = xsd.Validate( xmlFiles, true );

            if ( !result.IsValid && result.XmlErrors.Any( p => p.XmlExceptionOccurred ) )
            {
                return result;
            }

            resources.LoadResources( mod );

            result.XmlErrors.AddRange(
                XmlResourceValidator.Validate(
                    xmlFiles.Where( p => p.Name.ToLower() != "mod.xml" ),
                    resources,
                    ExpansionResourcesUsed
                )
                .Where( p => p.Errors.Count > 0 )
            );

            result.ExpansionResourcedUsed = ExpansionResourcesUsed;

            result.ExpansionNumbersUsed =
                ExpansionResourcesUsed.Animations.Select( p => p.ExpansionNumber )
                .Concat( result.ExpansionResourcedUsed.Files.Select( p => p.ExpansionNumber ) )
                .Concat( result.ExpansionResourcedUsed.ContentResources.Select( p => p.ExpansionNumber ) )
                .Distinct()
                .OrderBy( p => p )
                .ToList();

            AddRequirementErrors( result, modFile );

            return result;
        }
Пример #3
0
        /// <summary>
        /// Performs XML and XSD validation. If no files are malformed the performs resource validation.
        /// </summary>
        /// <returns></returns>
        public CoreValidationResult Validate()
        {
            CoreValidationResult result = new CoreValidationResult();

            var xmlFiles = core.EnumerateXmlFiles( DredmorInfo.XmlFilesToValidate, SearchOption.AllDirectories );

            XsdValidator xsd = new XsdValidator();
            result.XmlErrors = xsd.Validate( xmlFiles, true );

            if ( !result.IsValid && result.XmlErrors.Any( p => p.XmlExceptionOccurred ) )
            {
                return result;
            }

            resources.LoadResources( core );

            result.XmlErrors.AddRange(
                XmlResourceValidator.Validate( xmlFiles, resources )
                .Where( p => p.Errors.Count > 0 )
            );

            return result;
        }
Пример #4
0
        /// <summary>
        /// Performs XML and XSD validation. If no files are malformed the performs resource validation.
        /// </summary>
        /// <returns></returns>
        public CoreValidationResult Validate()
        {
            CoreValidationResult result = new CoreValidationResult();

            var xmlFiles = core.EnumerateXmlFiles(DredmorInfo.XmlFilesToValidate, SearchOption.AllDirectories);

            XsdValidator xsd = new XsdValidator();

            result.XmlErrors = xsd.Validate(xmlFiles, true);

            if (!result.IsValid && result.XmlErrors.Any(p => p.XmlExceptionOccurred))
            {
                return(result);
            }

            resources.LoadResources(core);

            result.XmlErrors.AddRange(
                XmlResourceValidator.Validate(xmlFiles, resources)
                .Where(p => p.Errors.Count > 0)
                );

            return(result);
        }