Пример #1
0
 private void EnqueueRevalidation(RevalidationRequest target)
 {
     if (!_currentlyValidating.Contains(target))
     {
         _validationQueue.Enqueue(target);
     }
 }
Пример #2
0
            public void Enqueue(RevalidationRequest request)
            {
                if (_set.Contains(request))
                {
                    return;
                }

                _set.Add(request);
                _queue.Enqueue(request);
            }
Пример #3
0
        public void ManuallyEndValidation(
            IViewModel target,
            IVMPropertyDescriptor targetProperty
            )
        {
            var equivalentRequest = new RevalidationRequest(target, targetProperty);

            _currentlyValidating.Remove(equivalentRequest);

            IBehaviorContext context = target.Kernel.GetContext();

            targetProperty.Behaviors.EndValidationNext(context);
        }
Пример #4
0
        public void ProcessPendingValidations()
        {
            while (_validationQueue.HasRequests)
            {
                // We dequeue the request after the revalidation to avoid that the same
                // request that is currently processed is added to the queue again.

                RevalidationRequest r = _validationQueue.Peek();
                r.PerformRevalidation(this);

                _validationQueue.Dequeue();
            }
        }
Пример #5
0
        private CollectionResult ValidateCollectionIfNotInCache(ICollectionValidationTarget target)
        {
            CollectionResult cachedResult = _cachedCollectionResults
                                            .FirstOrDefault(cached => target.Equals(cached.Target));

            if (cachedResult == null)
            {
                cachedResult = CollectionValidationController.Validate(target);
                _cachedCollectionResults.Add(cachedResult);

                foreach (IViewModel item in cachedResult.PossiblyStaleItems)
                {
                    var r = new RevalidationRequest(item, target.Property);
                    EnqueueRevalidation(r);
                }
            }

            return(cachedResult);
        }