public DefaultDocumentValidatorFactory(
     DocumentValidatorContextPool contextPool,
     IValidationConfiguration configuration)
 {
     _contextPool   = contextPool;
     _configuration = configuration;
 }
Exemplo n.º 2
0
    /// <summary>
    /// Creates a new instance of <see cref="DocumentValidator"/>.
    /// </summary>
    /// <param name="contextPool">
    /// The document validator context pool.
    /// </param>
    /// <param name="rules">
    /// The validation rules.
    /// </param>
    /// <exception cref="ArgumentNullException"></exception>
    public DocumentValidator(
        DocumentValidatorContextPool contextPool,
        IEnumerable <IDocumentValidatorRule> rules)
    {
        if (rules is null)
        {
            throw new ArgumentNullException(nameof(rules));
        }

        _contextPool       = contextPool ?? throw new ArgumentNullException(nameof(contextPool));
        _allRules          = rules.ToArray();
        _nonCacheableRules = _allRules.Where(t => !t.IsCacheable).ToArray();
    }
Exemplo n.º 3
0
    public OperationComplexityMiddleware(
        RequestDelegate next,
        DocumentValidatorContextPool contextPool,
        IComplexityAnalyzerOptionsAccessor options,
        IComplexityAnalyzerCache cache,
        VariableCoercionHelper coercionHelper)
    {
        _next = next ??
                throw new ArgumentNullException(nameof(next));
        _contextPool = contextPool ??
                       throw new ArgumentNullException(nameof(contextPool));
        _settings = options?.Complexity ??
                    throw new ArgumentNullException(nameof(options));
        _cache = cache ??
                 throw new ArgumentNullException(nameof(cache));
        _coercionHelper = coercionHelper ??
                          throw new ArgumentNullException(nameof(coercionHelper));

        _compiler = new ComplexityAnalyzerCompilerVisitor(_settings);
    }