/// <summary> /// Raises the BeforeNameChangedEvent event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnBeforeNameChanged(object sender, NameChangeEventArgs e) { if (!NameValidator.IsValid(e.NameAfter)) { throw new NameNotValidException(e.NameAfter); } if (this.BeforeNameChanged != null) { this.BeforeNameChanged(sender, e); } }
/// <summary> /// Captures and handles the BeforeAddressNameAddressChanged event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnBeforeAddressNameAddressChanged(object sender, NameChangeEventArgs e) { try { foreach (AddressBookItem item in base.InnerList) { if (string.Compare(item.Name, e.NameAfter, true) == 0) { throw new NameNotUniqueException(item.Name); } } } catch (Exception ex) { e.Cancel = true; throw ex; } }
/// <summary> /// Raises the BeforeNameChangedEvent event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnBeforeNameChanged(object sender, NameChangeEventArgs e) { if (!NameValidator.IsValid(e.NameAfter)) throw new NameNotValidException(e.NameAfter); if (this.BeforeNameChanged != null) this.BeforeNameChanged(sender, e); }
/// <summary> /// Captures and handles the BeforeAddressNameAddressChanged event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnBeforeAddressNameAddressChanged(object sender, NameChangeEventArgs e) { try { foreach(AddressBookItem item in base.InnerList) if (string.Compare(item.Name, e.NameAfter, true) == 0) throw new NameNotUniqueException(item.Name); } catch(Exception ex) { e.Cancel = true; throw ex; } }