Beispiel #1
0
        /// <summary>
        /// Validates the entity against all shared and instance rules.
        /// </summary>
        public void CheckAllRules()
        {
            if (this.IsLoading)
            {
                throw new InvalidOperationException(Strings.EndLoadingNeverCalledAfterBeginLoading);
            }
            _entityBrokenValidationRules.Clear();

            var validationResult = this.ModelRulesInvoker.CheckAllValidationRules(this);

            _entityBrokenValidationRules.Add(validationResult);
            RaisePropertyChanged(nameof(Error));

            if (_entityBrokenValidationRules.HasErrors)
            {
                InternalRaisePropertyChanged(nameof(Error));
                InternalRaisePropertyChanged(nameof(IsValid));
                InternalRaisePropertyChanged(nameof(IsNotValid));
            }
        }
 public IEnumerable <IBrokenRule> InvalidRules(bool recheck = true)
 {
     if (recheck || brokenRules == null)
     {
         brokenRules = new BrokenValidationRules();
         List <IRule> lst = new List <IRule>();
         foreach (IRule rle in this)
         {
             if (rle.IsBroken(RuledItem))
             {
                 brokenRules.Add(new BrokenRule(rle, this));
             }
         }
     }
     return(brokenRules);
 }