/// <summary> /// Evaluates the violations for the rule. /// </summary> /// <remarks></remarks> public override IEnumerable <ValidationResult> Validate() { List <ValidationResult> errors = new List <ValidationResult>(); this.ValidateObject(); tracer.Info( Resources.ValidateGuidanceDocument_TraceInitial, this.CurrentElement.InstanceName); // Get guidance document path var documentFilePath = GuidanceDocumentHelper.GetDocumentPath(tracer, this.CurrentElement.AsElement(), this.UriReferenceService); if (this.processor == null) { this.processor = new TocGuidanceProcessor(documentFilePath, this.CurrentElement.Parent.Parent.PatternToolkitInfo.Identifier, this.CurrentElement.ProjectContentPath); } // Validate document errors.AddRange(this.processor.ValidateDocument()); tracer.Info( Resources.ValidateGuidanceDocument_TraceValidation, this.CurrentElement.InstanceName, !errors.Any()); return(errors); }
/// <summary> /// Evaluates the violations for the rule. /// </summary> /// <remarks></remarks> public override IEnumerable<ValidationResult> Validate() { List<ValidationResult> errors = new List<ValidationResult>(); this.ValidateObject(); tracer.Info( Resources.ValidateGuidanceDocument_TraceInitial, this.CurrentElement.InstanceName); // Get guidance document path var documentFilePath = GuidanceDocumentHelper.GetDocumentPath(tracer, this.CurrentElement.AsElement(), this.UriReferenceService); if (this.processor == null) { this.processor = new TocGuidanceProcessor(documentFilePath, this.CurrentElement.Parent.Parent.PatternToolkitInfo.Identifier, this.CurrentElement.ProjectContentPath); } // Validate document errors.AddRange(this.processor.ValidateDocument()); tracer.Info( Resources.ValidateGuidanceDocument_TraceValidation, this.CurrentElement.InstanceName, !errors.Any()); return errors; }
/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { this.ValidateObject(); tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceInitial, this.CurrentElement.InstanceName); // Get guidance document path var documentFilePath = GuidanceDocumentHelper.GetDocumentPath(tracer, this.CurrentElement.AsElement(), this.UriReferenceService); if (this.processor == null) { this.processor = new TocGuidanceProcessor(documentFilePath, this.CurrentElement.Parent.Parent.PatternToolkitInfo.Identifier, this.CurrentElement.ProjectContentPath); } // Validate document first tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceValidatingDocument, documentFilePath); this.ErrorList.Clear(documentFilePath); var errors = this.processor.ValidateDocument(); if (errors.Any()) { tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceDocumentValidationFailed, documentFilePath, errors.Count()); this.ErrorList.AddRange(documentFilePath, errors); return; } // Ensure content container exists var container = EnsureContentContainer(); if (container == null) { return; } var tempPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); try { // Generate documents to temporary location tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceTempGeneration, tempPath); var generatedFiles = this.processor.GenerateWorkflowDocuments(tempPath); tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceSyncingDocuments, tempPath, container.GetLogicalPath()); // Rationalize generated documents with project container SyncGeneratedProjectFiles(generatedFiles.ToDictionary <string, string>(gf => gf), tempPath, container); } finally { CleanupGeneratedDocuments(tempPath); } }
/// <summary> /// Creates a new instance of the <see cref="CreateGuidanceDocumentsCommand"/> class. /// </summary> /// <remarks>This is for testing only.</remarks> internal CreateGuidanceDocumentsCommand(IGuidanceProcessor processor) : this() { this.processor = processor; }
/// <summary> /// Executes this commmand. /// </summary> /// <remarks></remarks> public override void Execute() { this.ValidateObject(); tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceInitial, this.CurrentElement.InstanceName); // Get guidance document path var documentFilePath = GuidanceDocumentHelper.GetDocumentPath(tracer, this.CurrentElement.AsElement(), this.UriReferenceService); if (this.processor == null) { this.processor = new TocGuidanceProcessor(documentFilePath, this.CurrentElement.Parent.Parent.PatternToolkitInfo.Identifier, this.CurrentElement.ProjectContentPath); } // Validate document first tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceValidatingDocument, documentFilePath); this.ErrorList.Clear(documentFilePath); var errors = this.processor.ValidateDocument(); if (errors.Any()) { tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceDocumentValidationFailed, documentFilePath, errors.Count()); this.ErrorList.AddRange(documentFilePath, errors); return; } // Ensure content container exists var container = EnsureContentContainer(); if (container == null) { return; } var tempPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); try { // Generate documents to temporary location tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceTempGeneration, tempPath); var generatedFiles = this.processor.GenerateWorkflowDocuments(tempPath); tracer.Info( Resources.CreateGuidanceDocumentsCommand_TraceSyncingDocuments, tempPath, container.GetLogicalPath()); // Rationalize generated documents with project container SyncGeneratedProjectFiles(generatedFiles.ToDictionary<string, string>(gf => gf), tempPath, container); } finally { CleanupGeneratedDocuments(tempPath); } }