Exemplo n.º 1
0
        public async Task <IEnumerable <IValidationError> > ExecuteAsync(IEnumerable <T> validationItems, CancellationToken cancellationToken)
        {
            List <TRule> ruleSet = _ruleSetResolutionService.Resolve().ToList();

            foreach (T validationItem in validationItems ?? Enumerable.Empty <T>())
            {
                cancellationToken.ThrowIfCancellationRequested();

                _ruleSetExecutionService.Execute(ruleSet, validationItem);
            }

            return(_validationErrorCache.ValidationErrors);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <U> > ExecuteAsync(IEnumerable <string> ignoredRules, CancellationToken cancellationToken)
        {
            List <IRule <T> > ruleSet = _ruleSetResolutionService.Resolve().Where(x => !ignoredRules.Any(y => string.Equals(x.RuleName, y, StringComparison.OrdinalIgnoreCase))).ToList();

            IEnumerable <T> items = await _validationItemProviderService.ProvideAsync(cancellationToken);

            foreach (T validationItem in items)
            {
                cancellationToken.ThrowIfCancellationRequested();

                _ruleSetExecutionService.Execute(ruleSet, validationItem);
            }

            return(_validationErrorCache.ValidationErrors);
        }
        public async Task <IEnumerable <U> > Execute(CancellationToken cancellationToken)
        {
            var ruleSet = _ruleSetResolutionService.Resolve().ToList();

            IEnumerable <T> items = await _validationItemProviderService.ProvideAsync(cancellationToken);

            foreach (T validationItem in items)
            {
                cancellationToken.ThrowIfCancellationRequested();

                _ruleSetExecutionService.Execute(ruleSet, validationItem);
            }

            return(_validationErrorCache.ValidationErrors);
        }