Ejemplo n.º 1
0
        /// <summary>
        /// Occurs during the copy process and overrides the base behavior so that events are suspended.
        /// </summary>
        /// <param name="copy">The copy.</param>
        protected override void OnCopy(CopyList <T> copy)
        {
            ChangeEventList <T> myCopy = copy as ChangeEventList <T>;

            if (myCopy != null)
            {
                RemoveHandlers(myCopy);
                myCopy.SuspendEvents();
            }

            base.OnCopy(copy);
            myCopy?.ResumeEvents();
        }
Ejemplo n.º 2
0
 private static void RemoveHandlers(ChangeEventList <T> myCopy)
 {
     if (myCopy.ItemChanged != null)
     {
         foreach (var handler in myCopy.ItemChanged.GetInvocationList())
         {
             myCopy.ItemChanged -= (EventHandler)handler;
         }
     }
     if (myCopy.RemoveItem != null)
     {
         foreach (var handler in myCopy.RemoveItem.GetInvocationList())
         {
             myCopy.RemoveItem -= (EventHandler)handler;
         }
     }
 }