public virtual XDocument Load(string path) { path.ThrowOnNullOrWhiteSpace(nameof(path)); try { if (!File.Exists(path)) { return(null); } var document = XDocument.Load(path); if (document == null) { return(null); } else if (FileValidation != null && !FileValidation.ValidateSuppressionFile(document)) { return(null); } return(document); } catch (Exception exception) when(FilterException(exception)) { ErrorProcessor.ProcessError(exception); } return(null); }
public virtual bool ValidateSuppressionFile(XDocument document) { document.ThrowOnNull(nameof(document)); ValidationLog validationLog = new ValidationLog(); foreach (ISuppressionFileValidator validator in AggregatedValidators) { validator.ValidateSuppressionFile(document, validationLog); } if (validationLog.ErrorsCount == 0) { return(true); } if (ErrorProcessor == null) { return(false); } string log = validationLog.GetValidationLog(); if (log.IsNullOrWhiteSpace()) { log = "Validation of suppression file failed"; } ErrorProcessor.ProcessError(new Exception(log)); return(false); }
public virtual bool Save(XDocument document, string path) { document.ThrowOnNull(nameof(document)); path.ThrowOnNullOrWhiteSpace(nameof(path)); try { if (FileValidation != null && !FileValidation.ValidateSuppressionFile(document)) { return(false); } document.Save(path); } catch (Exception exception) when(FilterException(exception)) { ErrorProcessor.ProcessError(exception); return(false); } return(true); }