private void ValidateName(ValidationContext context) { string msg = ""; if (!NamingHelper.TryValidateBaseName(this, this.Name, NamingHelper.ValidationOptions.IsRequired, out msg)) { context.LogError(msg, "RequiredProperty", this); } }
protected override void OnValueChanged(TypeBase element, string oldValue, string newValue) { // Don't run in an undo or when store is loading from file (CSD with issue could never open!). if (!element.Store.InUndoRedoOrRollback && !element.Store.InSerializationTransaction) { newValue = newValue.Trim(); // Trim and set new value in case user adds spaces by accident. element.Name = newValue; // We will want to use more specific validation if possible, which is done in overrides (property vs element vs section). // Hard validation of the new name. string msg = ""; if (!NamingHelper.TryValidateBaseName(element, newValue, NamingHelper.ValidationOptions.None, out msg)) { throw new ArgumentException(msg, element.GetType().Name); } // 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); }