Esempio n. 1
0
        void Validate()
        {
            if (Validator != null)
            {
                lock (lockObj)
                {
                    ValidationResult results = Validator.Validate();
                    if (results != null)
                    {
                        // reset error container
                        ErrorsContainer.ClearAllErrors();

                        List <string> errorPropertyNames = results.Errors.Select(x => x.PropertyName).ToList();
                        if ((errorPropertyNames != null) && (errorPropertyNames.Count > 0))
                        {
                            foreach (var propertyName in errorPropertyNames)
                            {
                                List <string> errorMessages = results.Errors.Where(pn => pn.PropertyName.ToLower() == propertyName.ToLower()).Select(x => x.ErrorMessage).ToList();
                                ErrorsContainer.SetErrors(propertyName, errorMessages);
                                OnErrorsChanged(propertyName);
                            }
                        }
                    }
                }
            }
        }