public static IQueryExecutionBuilder AddQueryValidation( this IQueryExecutionBuilder builder, IValidateQueryOptionsAccessor options) { builder.Services.AddQueryValidation(options); return(builder); }
public MaxComplexityRule( IValidateQueryOptionsAccessor options, ComplexityCalculation calculateComplexity) { _options = options ?? throw new ArgumentNullException(nameof(options)); _calculateComplexity = calculateComplexity ?? DefaultComplexity; }
public MaxDepthVisitor(IValidateQueryOptionsAccessor options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _maxExecutionDepth = options.MaxExecutionDepth ?? int.MaxValue; }
public MaxComplexityMiddleware( QueryDelegate next, IValidateQueryOptionsAccessor options, ComplexityCalculation complexityCalculation) { _next = next ?? throw new ArgumentNullException(nameof(next)); _options = options ?? throw new ArgumentNullException(nameof(options)); _calculation = complexityCalculation ?? DefaultComplexity; }
private IQueryValidator CreateValidator( IValidateQueryOptionsAccessor options) { var services = new ServiceCollection(); services.AddQueryValidation(options); services.AddDefaultValidationRules(); return(services.BuildServiceProvider() .GetRequiredService <IQueryValidator>()); }
public static IServiceCollection AddQueryValidation( this IServiceCollection services, IValidateQueryOptionsAccessor options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } return(services .AddSingleton(options) .AddSingleton <IQueryValidator, QueryValidator>()); }
public ValidateQueryMiddleware( QueryDelegate next, IQueryValidator validator, Cache <QueryValidationResult> validatorCache, IValidateQueryOptionsAccessor options) { _next = next ?? throw new ArgumentNullException(nameof(next)); _validator = validator ?? throw new ArgumentNullException(nameof(validator)); _validatorCache = validatorCache ?? new Cache <QueryValidationResult>(Defaults.CacheSize); _options = options ?? throw new ArgumentNullException(nameof(options)); }
public MaxDepthVisitor(IValidateQueryOptionsAccessor options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (!options.MaxExecutionDepth.HasValue) { throw new ArgumentException( "The max depth visitor can only be used " + "if a max query depth is defined."); } _maxExecutionDepth = options.MaxExecutionDepth.Value; }
public static IQueryExecutionBuilder AddQueryValidation( this IQueryExecutionBuilder builder, IValidateQueryOptionsAccessor options) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } builder.Services.AddQueryValidation(options); return(builder); }
public MaxDepthRule(IValidateQueryOptionsAccessor options) { _options = options ?? throw new ArgumentNullException(nameof(options)); _visitor = new MaxDepthVisitor(_options); }