public DemoChild(DemoChild original) { #pragma warning restore CS8618 // Key = StorageExtensions.NoKey; DemoChildData = original.DemoChildData; Parent = original.Parent; onCloned(this); }
public void Update(string demoChildData, DemoParent parent) { if (Key >= 0) { if (parent.Key < 0) { throw new Exception($"DemoChild.Update(): It is illegal to add stored DemoChild '{this}'" + Environment.NewLine + $"to Parent '{parent}', which is not stored."); } } var clone = new DemoChild(this); var isCancelled = false; onUpdating(demoChildData, parent, ref isCancelled); if (isCancelled) { return; } #if DEBUG DC.Trace?.Invoke($"Updating DemoChild: {ToTraceString()}"); #endif var isChangeDetected = false; if (DemoChildData != demoChildData) { DemoChildData = demoChildData; isChangeDetected = true; } if (Parent != parent) { Parent.RemoveFromDemoChildren(this); Parent = parent; Parent.AddToDemoChildren(this); isChangeDetected = true; } if (isChangeDetected) { onUpdated(clone); if (Key >= 0) { DC.Data.DemoChildren.ItemHasChanged(clone, this); } else if (DC.Data.IsTransaction) { DC.Data.AddTransaction(new TransactionItem(35, TransactionActivityEnum.Update, Key, this, oldItem: clone)); } HasChanged?.Invoke(clone, this); } #if DEBUG DC.Trace?.Invoke($"Updated DemoChild: {ToTraceString()}"); #endif }
public DemoChild(string demoChildData, DemoParent parent, bool isStoring = true) { Key = StorageExtensions.NoKey; DemoChildData = demoChildData; Parent = parent; #if DEBUG DC.Trace?.Invoke($"new DemoChild: {ToTraceString()}"); #endif Parent.AddToDemoChildren(this); onConstruct(); if (DC.Data?.IsTransaction ?? false) { DC.Data.AddTransaction(new TransactionItem(35, TransactionActivityEnum.New, Key, this)); } if (isStoring) { Store(); } }
private DemoChild(int key, CsvReader csvReader) { Key = key; DemoChildData = csvReader.ReadString(); var demoParentKey = csvReader.ReadInt(); if (DC.Data.DemoParents.TryGetValue(demoParentKey, out var parent)) { Parent = parent; } else { throw new Exception($"Read DemoChild from CSV file: Cannot find Parent with key {demoParentKey}." + Environment.NewLine + csvReader.PresentContent); } if (Parent != DemoParent.NoDemoParent) { Parent.AddToDemoChildren(this); } onCsvConstruct(); }
/// <summary> /// Called before any property of DemoChild is updated and before the HasChanged event gets raised /// </summary> partial void onUpdating(string demoChildData, DemoParent parent, ref bool isCancelled) { }