Пример #1
0
 public Validation(object target, object[] scopes)
 {
     if (target == null)
     {
         throw new ArgumentNullException(nameof(target));
     }
     Target        = target;
     Outcome       = new ValidationOutcome();
     ScopeMatcher  = CreateScopeMatcher(scopes);
     _asyncResults = new List <Promise>();
 }
Пример #2
0
        private ValidationOutcome GetOrCreateOutcome(string propertyName, bool create = false)
        {
            var errors = _errors.GetOrAdd(propertyName, _ => new List <object>());

            lock (errors)
            {
                var outcome = errors.OfType <ValidationOutcome>().FirstOrDefault();
                if (outcome == null && create)
                {
                    outcome = new ValidationOutcome();
                    errors.Add(outcome);
                    outcome.ErrorsChanged += (s, e) =>
                                             RaiseErrorsChanged($"{propertyName}.{e.PropertyName}");
                }
                return(outcome);
            }
        }
Пример #3
0
 public ValidationException(ValidationOutcome outcome)
     : base(outcome.Error)
 {
     Outcome = outcome;
 }
Пример #4
0
 public ValidationException(string message, ValidationOutcome outcome)
     : base(message)
 {
     Outcome = outcome;
 }