예제 #1
0
        /// <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);
            }
        }
예제 #2
0
 /// <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;
			}
		}