public void Update(string text, NotMatchingChildrenListName_Parent parent) { if (Key >= 0) { if (parent.Key < 0) { throw new Exception($"NotMatchingChildrenListName_Child.Update(): It is illegal to add stored NotMatchingChildrenListName_Child '{this}'" + Environment.NewLine + $"to Parent '{parent}', which is not stored."); } } var clone = new NotMatchingChildrenListName_Child(this); var isCancelled = false; onUpdating(text, parent, ref isCancelled); if (isCancelled) { return; } #if DEBUG DC.Trace?.Invoke($"Updating NotMatchingChildrenListName_Child: {ToTraceString()}"); #endif var isChangeDetected = false; if (Text != text) { Text = text; isChangeDetected = true; } if (Parent != parent) { Parent.RemoveFromChildren(this); Parent = parent; Parent.AddToChildren(this); isChangeDetected = true; } if (isChangeDetected) { onUpdated(clone); if (Key >= 0) { DC.Data.NotMatchingChildrenListName_Childs.ItemHasChanged(clone, this); } else if (DC.Data.IsTransaction) { DC.Data.AddTransaction(new TransactionItem(37, TransactionActivityEnum.Update, Key, this, oldItem: clone)); } HasChanged?.Invoke(clone, this); } #if DEBUG DC.Trace?.Invoke($"Updated NotMatchingChildrenListName_Child: {ToTraceString()}"); #endif }
public NotMatchingChildrenListName_Child(string text, NotMatchingChildrenListName_Parent parent, bool isStoring = true) { Key = StorageExtensions.NoKey; Text = text; Parent = parent; #if DEBUG DC.Trace?.Invoke($"new NotMatchingChildrenListName_Child: {ToTraceString()}"); #endif Parent.AddToChildren(this); onConstruct(); if (DC.Data?.IsTransaction ?? false) { DC.Data.AddTransaction(new TransactionItem(37, TransactionActivityEnum.New, Key, this)); } if (isStoring) { Store(); } }