/// <summary> /// Initializes a new instance of the ValidationSettings. /// </summary> /// <param name="fileFormat">The target file format.</param> public ValidationSettings(FileFormatVersions fileFormat) { fileFormat.ThrowExceptionIfFileFormatNotSupported(nameof(fileFormat)); FileFormat = fileFormat; MaxNumberOfErrors = _defaultMaxNumberOfErrorsReturned; }
/// <summary> /// Initializes a new instance of the ValidationSettings. /// </summary> /// <param name="fileFormat">The target file format.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, or FileFormat.Office2010 or FileFormat.Office2013.</exception> internal ValidationSettings(FileFormatVersions fileFormat) { fileFormat.ThrowExceptionIfFileFormatNotSupported("fileFormat"); this.FileFormat = fileFormat; this.MaxNumberOfErrors = _defaultMaxNumberOfErrorsReturned; }
/// <summary> /// Initializes a new instance of the OpenXmlValidator. /// </summary> /// <param name="fileFormat">The target file format to be validated against.</param> /// <remarks> /// Default to FileFormat.Office2007. /// </remarks> /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="fileFormat"/> parameter is not a known format.</exception> public OpenXmlValidator(FileFormatVersions fileFormat) { fileFormat.ThrowExceptionIfFileFormatNotSupported(nameof(fileFormat)); _settings = new ValidationSettings(fileFormat); _cache = new ValidationCache(fileFormat); }
/// <summary> /// Initializes a new instance of the ValidationSettings. /// </summary> /// <param name="fileFormat">The target file format.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, FileFormat.Office2010, FileFormat.Office2013, or FileFormat.Office2016.</exception> internal ValidationSettings(FileFormatVersions fileFormat) { fileFormat.ThrowExceptionIfFileFormatNotSupported("fileFormat"); this.FileFormat = fileFormat; this.MaxNumberOfErrors = _defaultMaxNumberOfErrorsReturned; }
/// <summary> /// Throws if the <see cref="OpenXmlElement"/> is not supported in the given version /// </summary> /// <param name="version">Version to check</param> /// <param name="element">Element to validate</param> public static void ThrowIfNotInVersion(this FileFormatVersions version, OpenXmlElement element) { version.ThrowExceptionIfFileFormatNotSupported(nameof(version)); if (!element.IsInVersion(version)) { throw new InvalidOperationException(SR.Format(ExceptionMessages.ElementIsNotInOfficeVersion, version.GetOfficeYear())); } }
/// <summary> /// Throws if the <see cref="OpenXmlElement"/> is not supported in the given version /// </summary> /// <param name="version">Version to check</param> /// <param name="element">Element to validate</param> public static void ThrowIfNotInVersion(this FileFormatVersions version, OpenXmlElement element) { version.ThrowExceptionIfFileFormatNotSupported(nameof(version)); if (!element.IsInVersion(version)) { var message = string.Format(CultureInfo.CurrentCulture, ExceptionMessages.ElementIsNotInOfficeVersion, version.GetOfficeYear()); throw new InvalidOperationException(message); } }
/// <summary> /// Initializes a new instance of the OpenXmlValidator. /// </summary> /// <param name="fileFormat">The target filr format to be validated aginst.</param> /// <remarks> /// Default to FileFormat.Office2007. /// </remarks> /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, FileFormat.Office2010 or FileFormat.O15.</exception> public OpenXmlValidator(FileFormatVersions fileFormat) { fileFormat.ThrowExceptionIfFileFormatNotSupported("fileFormat"); this._settings = new ValidationSettings(fileFormat); }