Skip to content

Commit

Permalink
Use LINQ instead of foreach()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mc-Pain committed Dec 24, 2022
1 parent 02a3c7f commit 781e656
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions EDEngineer/Views/ShoppingListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,12 @@ public IEnumerator<Blueprint> GetEnumerator()
yield break;
}

var composition = new List<BlueprintIngredient>();
foreach (var i in ingredients)
{
composition.Add(new BlueprintIngredient(i.Key, i.Value));
}

composition = composition.OrderBy(i => i.Entry.Count - i.Size > 0 ? 1 : 0)
.ThenByDescending(i => i.Entry.Data.Subkind)
.ThenBy(i => i.Entry.Data.Kind)
.ThenBy(i => languages.Translate(i.Entry.Data.Name))
.ToList();
var composition = ingredients.Select(i => new BlueprintIngredient(i.Key, i.Value))
.OrderBy(i => i.Entry.Count - i.Size > 0 ? 1 : 0)
.ThenByDescending(i => i.Entry.Data.Subkind)
.ThenBy(i => i.Entry.Data.Kind)
.ThenBy(i => languages.Translate(i.Entry.Data.Name))
.ToList();

var metaBlueprint = new Blueprint(languages,
"",
Expand Down

0 comments on commit 781e656

Please sign in to comment.