Beispiel #1
0
 private void ValidateName(ValidationContext context)
 {
     if (string.IsNullOrEmpty(this.Name))
     {
         context.LogError("The Name is required and cannot be an empty string.", "RequiredProperty", this);
     }
     if (!NamingHelper.IsValidName(this.Name))
     {
         context.LogError(Resources.Error_InvalidName, "RequiredProperty", this);
     }
 }
Beispiel #2
0
            protected override void OnValueChanged(TypeBase element, string oldValue, string newValue)
            {
                if (!element.Store.InUndoRedoOrRollback)
                {
                    // Hard validation of the new name.
                    if (string.IsNullOrEmpty(newValue))
                    {
                        throw new ArgumentException("The Name is required and cannot be an empty string.", newValue);
                    }
                    if (!NamingHelper.IsValidName(newValue))
                    {
                        throw new ArgumentException(Resources.Error_InvalidName, newValue);
                    }
                    // Raise the NameChanged event for derived classes to act upon.
                    element.OnNameChanged(EventArgs.Empty);
                }

                // Always call the base class method.
                base.OnValueChanged(element, oldValue, newValue);
            }