/// <summary> /// Validates the specified <see cref="Snippet"/> according the the code snippet schema. /// </summary> /// <param name="snippet">A <see cref="Snippet"/> that is being validated.</param> /// <returns>A <see cref="SnippetValidationContext"/> that stores data about the validation.</returns> public IEnumerable<SnippetValidationResult> Validate(Snippet snippet) { if (snippet == null) throw new ArgumentNullException(nameof(snippet)); var context = new SnippetValidationContext(snippet); foreach (SnippetValidationResult result in Validate(context)) yield return result; }
/// <summary> /// Validates the specified <see cref="Snippet"/> according the the code snippet schema. /// </summary> /// <param name="context">A <see cref="SnippetValidationContext"/> that stores data about the validation.</param> protected virtual IEnumerable<SnippetValidationResult> Validate(SnippetValidationContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); foreach (ValidationRule rule in ValidationRules) { foreach (SnippetValidationResult result in rule.Validate(context.Snippet)) yield return result; } }
/// <summary> /// Validates the specified <see cref="Snippet"/> according the the code snippet schema. /// </summary> /// <param name="snippet">A <see cref="Snippet"/> that is being validated.</param> /// <returns>A <see cref="SnippetValidationContext"/> that stores data about the validation.</returns> /// <exception cref="ArgumentNullException"><paramref name="snippet"/> is <c>null</c>.</exception> public IEnumerable <SnippetValidationResult> Validate(Snippet snippet) { if (snippet == null) { throw new ArgumentNullException(nameof(snippet)); } var context = new SnippetValidationContext(snippet); foreach (SnippetValidationResult result in Validate(context)) { yield return(result); } }
/// <summary> /// Validates the specified <see cref="Snippet"/> according the the code snippet schema. /// </summary> /// <param name="context">A <see cref="SnippetValidationContext"/> that stores data about the validation.</param> /// <exception cref="ArgumentNullException"><paramref name="context"/> is <c>null</c>.</exception> protected virtual IEnumerable <SnippetValidationResult> Validate(SnippetValidationContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } foreach (ValidationRule rule in ValidationRules) { foreach (SnippetValidationResult result in rule.Validate(context.Snippet)) { yield return(result); } } }