Esempio n. 1
0
        private Task ValidateInternalAsync(object item, ValidationContext <TState> context, CancellationToken token)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (context.MaxDegreeOfParallelism < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(context), context.MaxDegreeOfParallelism, SR.ParallelThreadNumberMustBeGreaterThan0);
            }

            return(SingletonList.Create(item).TraverseAsync(current => BuildItem(context, current), context.MaxDegreeOfParallelism, token));
        }
Esempio n. 2
0
        private void ValidateInternal(object item, ValidationContext <TState> context, CancellationToken token)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

#if FEATURE_PARALLEL
            if (context.MaxDegreeOfParallelism != 1)
            {
                throw new ArgumentOutOfRangeException(nameof(context), context.MaxDegreeOfParallelism, SR.ParallelThreadNumberMustBeOneForNonAsync);
            }
#endif

            SingletonList.Create(item).Traverse(current => BuildItem(context, current), token);
        }