'Returning a result dependent upon a combination of inputs

Consider a situation where we have a list containing some enumeration values and we must return a result that is dependent upon the combination of values present in this list. For example,

public enum Ingredient
{
  Meat,
  Vegetables,
  Broth
}

//...
public int extraIngredients;
public Dish GetDish(List<Ingredient> ingredients);

In this example, we want the following behavior from GetDish():

{Meat} => new Steak()

{Meat, Meat} => new Steak(); extraIngredients++

{Meat, Vegetables} => new StirFry()

{Meat, Meat, Vegetables, Vegetables} => new StirFry(); extraIngredients += 2

{Meat, Vegetables, Broth} => new Stew()

{Broth} => new Soup()

etc, etc.

We want the solution to be extensible in case new Ingredients are introduced in the future.

Essentially, every unique combination (NOT permutation) of Ingredients produces a unique Dish. Any duplicate Ingredients in the list triggers some defined side-effect. Does anyone have a lead on a clean solution to this? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source