/// <summary>
        ///     Construct a Change instance with actions for undo / redo.
        /// </summary>
        /// <param name="instance">The instance that changed.</param>
        /// <param name="propertyName">The property name that changed. (Case sensitive, used by reflection.)</param>
        /// <param name="oldValue">The old value of the property.</param>
        /// <param name="newValue">The new value of the property.</param>
        /// <param name="descriptionOfChange">A description of this change.</param>
        public virtual void OnChanging(object instance, string propertyName, object?oldValue, object?newValue,
                                       string descriptionOfChange)
        {
            var supportsUndo = instance as ISupportsUndo;

            if (null == supportsUndo)
            {
                return;
            }

            object?root = supportsUndo.GetUndoRoot();

            if (null == root)
            {
                return;
            }

            // Add the changes to the UndoRoot
            UndoRoot undoRoot = UndoService.Current[root];

            if (undoRoot.IsUndoingOrRedoing)
            {
                return;
            }

            Change?change = GetChange(instance, propertyName, oldValue, newValue);

            if (change is null)
            {
                return;
            }
            undoRoot.AddChange(change, descriptionOfChange);
        }
        /// <summary>
        ///     Construct a Change instance with actions for undo / redo.
        ///     Returns True, if is Undoing or Redoing, otherwise False.
        /// </summary>
        /// <param name="instance">The instance that changed.</param>
        /// <param name="propertyName">
        ///     The property name that exposes the collection that changed. (Case sensitive, used by
        ///     reflection.)
        /// </param>
        /// <param name="collection">The collection that had an item added / removed.</param>
        /// <param name="e">The NotifyCollectionChangedEventArgs event args parameter, with info about the collection change.</param>
        /// <param name="descriptionOfChange">A description of the change.</param>
        public virtual bool OnCollectionChanged(object instance, string propertyName, object collection,
                                                NotifyCollectionChangedEventArgs e, string descriptionOfChange)
        {
            ISupportsUndo?supportsUndo = instance as ISupportsUndo;

            if (null == supportsUndo)
            {
                return(false);
            }

            object?root = supportsUndo.GetUndoRoot();

            if (null == root)
            {
                return(false);
            }

            // Add the changes to the UndoRoot
            UndoRoot undoRoot = UndoService.Current[root];

            if (undoRoot.IsUndoingOrRedoing)
            {
                return(true);
            }

            // Create the Change instances.
            IList <Change>?changes = GetCollectionChange(instance, propertyName, collection, e);

            if (null == changes)
            {
                return(false);
            }

            foreach (Change change in changes)
            {
                undoRoot.AddChange(change, descriptionOfChange);
            }

            return(false);
        }