Encapsulate mutable collections in Bin and Result
Replace public mutable collection fields/properties with private backing fields and expose them as IReadOnlyList. Add proper methods for mutation (AddItem, AddItems, RemoveItem, SortItems). Changes: - Bin.Items: Now private with AddItem/AddItems/RemoveItem/SortItems - Result.ItemsNotUsed: Now readonly with Add methods - Result.Bins: Now readonly with Add methods - Updated all engine classes to use new encapsulated APIs This improves encapsulation and prevents external code from bypassing business logic by directly manipulating collections. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -29,11 +29,11 @@ namespace SawCut.Nesting
|
||||
e.Spacing = Spacing;
|
||||
var r = e.Pack(remainingItems);
|
||||
|
||||
result.Bins.AddRange(r.Bins);
|
||||
remainingItems = r.ItemsNotUsed;
|
||||
result.AddBins(r.Bins);
|
||||
remainingItems = r.ItemsNotUsed.ToList();
|
||||
}
|
||||
|
||||
result.ItemsNotUsed = remainingItems;
|
||||
result.AddItemsNotUsed(remainingItems);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user