internal void AddToChild(ParentOneChild_Child parentOneChild_Child) { #if DEBUG if (parentOneChild_Child == ParentOneChild_Child.NoParentOneChild_Child) { throw new Exception(); } if ((parentOneChild_Child.Key >= 0) && (Key < 0)) { throw new Exception(); } if (Child == parentOneChild_Child) { throw new Exception(); } #endif if (Child != null) { throw new Exception($"ParentOneChild_Parent.AddToChild(): '{Child}' is already assigned to Child, it is not possible to assign now '{parentOneChild_Child}'."); } Child = parentOneChild_Child; onAddedToChild(parentOneChild_Child); #if DEBUG DC.Trace?.Invoke($"Add ParentOneChild_Child {parentOneChild_Child.GetKeyOrHash()} to " + $"{this.GetKeyOrHash()} ParentOneChild_Parent.Child"); #endif }
internal void RemoveFromChild(ParentOneChild_Child parentOneChild_Child) { #if DEBUG if (Child != parentOneChild_Child) { throw new Exception($"ParentOneChild_Parent.RemoveFromChild(): Child does not link to parentOneChild_Child '{parentOneChild_Child}' but '{Child}'."); } #endif Child = null; onRemovedFromChild(parentOneChild_Child); #if DEBUG DC.Trace?.Invoke($"Remove ParentOneChild_Child {parentOneChild_Child.GetKeyOrHash()} from " + $"{this.GetKeyOrHash()} ParentOneChild_Parent.Child"); #endif }