//protected virtual void ResetChanged()
        //{
        //    lock (this)
        //    {
        //        if (this.AfterChanged != null)
        //        {
        //            Delegate[] invocationList = this.AfterChanged.GetInvocationList();
        //            if (invocationList != null)
        //            {
        //                foreach (Delegate subscriber in invocationList)
        //                {
        //                    this.AfterChanged -= (EventHandler<ObjectEventArgs>)subscriber;
        //                }
        //            }
        //        }
        //    }
        //}

        /// <summary>
        /// Raises the BeforeChanged event. The event will be cancelled if any exceptions are caught while raising the event.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The EventArgs for the event.</param>
        protected virtual void OnBeforeChanged(object sender, ObjectCancelEventArgs e)
        {
            try
            {
                // required for thread affinity
                EventHandler <ObjectCancelEventArgs> handler = this.BeforeChanged;
                if (handler != null)
                {
                    handler(sender, e);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);

                // capture the exception and cancel the change here
                e.Cancel = true;
            }
        }
		//protected virtual void ResetChanged()
		//{
		//    lock (this)
		//    {
		//        if (this.AfterChanged != null)
		//        {
		//            Delegate[] invocationList = this.AfterChanged.GetInvocationList();
		//            if (invocationList != null)
		//            {
		//                foreach (Delegate subscriber in invocationList)
		//                {
		//                    this.AfterChanged -= (EventHandler<ObjectEventArgs>)subscriber;
		//                }
		//            }
		//        }
		//    }
		//}

		/// <summary>
		/// Raises the BeforeChanged event. The event will be cancelled if any exceptions are caught while raising the event.
		/// </summary>
		/// <param name="sender">The sender of the event.</param>
		/// <param name="e">The EventArgs for the event.</param>
		protected virtual void OnBeforeChanged(object sender, ObjectCancelEventArgs e)
		{
			try
			{
				// required for thread affinity
				EventHandler<ObjectCancelEventArgs> handler = this.BeforeChanged;
				if (handler != null)
				{
					handler(sender, e);
				}				
			}
			catch (Exception ex)
			{
				Debug.WriteLine(ex);

				// capture the exception and cancel the change here
				e.Cancel = true;
			}				
		}