예제 #1
0
        public static ValidationResult Validate()
        {
            var projectMetadata  = ProjectMetadataService.GetProjectMetadata(GenContext.ToolBox.Shell.Project.GetActiveProjectPath());
            var templatesVersion = GenContext.ToolBox.TemplatesVersion.ToVersion();
            var projectVersion   = projectMetadata.TemplatesVersion.ToVersion();

            var validations = _validators
                              .Where(v => projectVersion <= v.BreakingVersion)
                              .Where(v => templatesVersion > v.BreakingVersion)
                              .Select(v => v.Validate()).ToList();

            return(new ValidationResult
            {
                IsValid = validations.All(v => v.IsValid),
                ErrorMessages = validations.SelectMany(v => v.ErrorMessages).ToList(),
            });
        }
        public ProjectMetadata ReadProjectConfiguration()
        {
            var projectPath     = _shell.GetActiveProjectPath();
            var projectMetadata = ProjectMetadataService.GetProjectMetadata(projectPath);

            if (IsValid(projectMetadata))
            {
                return(projectMetadata);
            }

            var inferredConfig = InferProjectConfiguration(projectMetadata);

            if (IsValid(inferredConfig))
            {
                ProjectMetadataService.SaveProjectMetadata(inferredConfig, projectPath);
            }

            return(inferredConfig);
        }