/// <summary> /// after a child has been replaced by a new chain spliced in place of it, this method will attempt to append the original child /// at the end of the chain which was spliced in. If that's not possible, then the original child is ejected /// </summary> /// <typeparam name="T"></typeparam> /// <param name="originalChild">The child which has been displaced from its parent</param> /// <param name="newChild">The head of the chainable chain which took the place of the original child</param> /// <returns></returns> public static void UpdateOriginalChildAfterSplice <T>(IChainableSeries <T> originalChild, IChainableSeries <T> newChild) { if (originalChild != null) { originalChild.SetParent(null); var newTerminator = GetChainTerminator(newChild); if (newTerminator.GetCanHaveChildren()) { //May not need to go full recursive here -- at this point, newTerminator has no children and originaChild has no parents // Could end up being a simple linking method?? newTerminator.SimpleAppendChild(originalChild); } else { //the new chain has a no-append terminator. Kick out the old chain after to replacing it with the new originalChild.OnSelfEjected(); } } }