Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 68e7b82

Browse files
committed
Use LINQ instead of foreach()
1 parent b0f6301 commit 68e7b82

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

EDEngineer/Views/ShoppingListViewModel.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,12 @@ public IEnumerator<Blueprint> GetEnumerator()
250250
yield break;
251251
}
252252

253-
var composition = new List<BlueprintIngredient>();
254-
foreach (var i in ingredients)
255-
{
256-
composition.Add(new BlueprintIngredient(i.Key, i.Value));
257-
}
258-
259-
composition = composition.OrderBy(i => i.Entry.Count - i.Size > 0 ? 1 : 0)
260-
.ThenByDescending(i => i.Entry.Data.Subkind)
261-
.ThenBy(i => i.Entry.Data.Kind)
262-
.ThenBy(i => languages.Translate(i.Entry.Data.Name))
263-
.ToList();
253+
var composition = ingredients.Select(i => new BlueprintIngredient(i.Key, i.Value))
254+
.OrderBy(i => i.Entry.Count - i.Size > 0 ? 1 : 0)
255+
.ThenByDescending(i => i.Entry.Data.Subkind)
256+
.ThenBy(i => i.Entry.Data.Kind)
257+
.ThenBy(i => languages.Translate(i.Entry.Data.Name))
258+
.ToList();
264259

265260
var metaBlueprint = new Blueprint(languages,
266261
"",

0 commit comments

Comments
 (0)