-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update variable names for readability
- Loading branch information
1 parent
acfd679
commit 7a375ad
Showing
1 changed file
with
13 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,7 +258,7 @@ public IProductType ConvertProductBack(ProductModel source, ProductType converte | |
private void UpdateCollection(IList value, IEnumerable<PartModel> parts) | ||
{ | ||
// Track which part links are still represented by the models | ||
var unused = new List<IProductPartLink>(value.OfType<IProductPartLink>()); | ||
var oldParts = new List<IProductPartLink>(value.OfType<IProductPartLink>()); | ||
// Iterate over the part models | ||
// Create or update the part links | ||
var elemType = value.GetType().GetInterfaces() | ||
|
@@ -269,27 +269,27 @@ private void UpdateCollection(IList value, IEnumerable<PartModel> parts) | |
if (partModel is null) | ||
continue; | ||
|
||
var match = unused.Find(r => r.Id == partModel?.Id); | ||
var oldPartMatch = oldParts.Find(r => r.Id == partModel.Id); | ||
// new partlink | ||
if (match == null) | ||
if (oldPartMatch == null) | ||
{ | ||
match = (IProductPartLink)Activator.CreateInstance(elemType); | ||
match.Product = _productManagement.LoadType(partModel.Product.Id); | ||
value.Add(match); | ||
oldPartMatch = (IProductPartLink)Activator.CreateInstance(elemType); | ||
oldPartMatch.Product = _productManagement.LoadType(partModel.Product.Id); | ||
value.Add(oldPartMatch); | ||
} | ||
//modified reference | ||
else if (match.Product.Id != partModel.Product.Id) | ||
match.Product = _productManagement.LoadType(partModel.Product.Id); | ||
else if (oldPartMatch.Product.Id != partModel.Product.Id) | ||
oldPartMatch.Product = _productManagement.LoadType(partModel.Product.Id); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
else | ||
//part removed | ||
unused.Remove(match); | ||
//part removed | ||
This comment has been minimized.
Sorry, something went wrong.
dacky179
Member
|
||
oldParts.Remove(oldPartMatch); | ||
|
||
EntryConvert.UpdateInstance(match, partModel.Properties); | ||
EntryConvert.UpdateInstance(oldPartMatch, partModel.Properties); | ||
} | ||
|
||
// Clear all values no longer present in the model | ||
foreach (var link in unused) | ||
value.Remove(link); | ||
foreach (var part in oldParts) | ||
value.Remove(part); | ||
} | ||
|
||
private void UpdateReference(IProductPartLink value, PartModel part) | ||
|
if i understand correctly we update the partlink; but at the end this partlink will be removed because it was not removed from "oldParts.
As this would be a bug with a great impact, i think this code won't be executed ever. @Toxantron ?