private void SendNotificationAfterValidation()
 {
     if (ParentCollection != null)
     {
         ParentCollection.RaiseValidationStatus(!HasValidationError);
     }
 }
예제 #2
0
        public string?this[string propertyName]
        {
            get
            {
                // Reset error condition
                string?error = null;
                HasValidationError = false;

                if (propertyName.Equals("Name", StringComparison.OrdinalIgnoreCase))
                {
                    if (IsNamePropertyEmpty())
                    {
                        error = PropertyPageResources.NameCannotBeEmpty;
                        HasValidationError = true;
                    }
                    else if (IsNamePropertyDuplicate())
                    {
                        error = PropertyPageResources.DuplicateKey;
                        HasValidationError = true;
                    }
                    else
                    {
                        // We are doing Row Validation - make sure that in addition to Name - Value is valid
                        HasValidationError = IsValuePropertyEmpty();
                    }
                }
                else if (propertyName.Equals("Value", StringComparison.OrdinalIgnoreCase))
                {
                    if (string.IsNullOrWhiteSpace(Value))
                    {
                        error = PropertyPageResources.ValueCannotBeEmpty;
                        HasValidationError = true;
                    }
                    else
                    {
                        // We are doing Row Validation - make sure that in addition to Value - Name is valid
                        HasValidationError = IsNamePropertyEmpty() || IsNamePropertyDuplicate();
                    }
                }

                _parentCollection?.RaiseValidationStatus(!HasValidationError);
                return(error);
            }
        }