/// <summary> /// Updates the DataBundleCollection, wherever possible updating only values and not changing the bound variables, to avoid reinjecting the collection. /// </summary> public void CopyValuesFrom(DataBundleCollection dataBundleCollection) { if (dataBundleCollection == this) { return; } List <DataBundle> remainingDataBundles = dataBundles.Where(db => dataBundleCollection.dataBundles.Contains(db)).ToList(); dataBundles.Clear(); foreach (DataBundle dataBundle in dataBundleCollection.dataBundles) { DataBundle existingDataBundle = remainingDataBundles.Find(db => db.id == dataBundle.id); if (existingDataBundle) { existingDataBundle.CopyValuesFrom(dataBundle); Add(existingDataBundle); } else { Add(dataBundle); } } }
public void AddOrUpdate(DataBundle dataBundle) { DataBundle existingDataBundle = GetDataBundle(dataBundle.id); if (existingDataBundle) { existingDataBundle.CopyValuesFrom(dataBundle); } else { Add(dataBundle); } }