示例#1
0
        // methods
        // loads and unloads sandwich variables during runtime
        public void BuildSub(string ingredient)
        {
            if (IngredientSource.Inventory["Bread"].ContainsKey(ingredient))
            {
                if (Bread.ItemName == ingredient)
                {
                    Bread = IngredientSource.Inventory["Bread"]["None"];
                }
                else
                {
                    Bread = IngredientSource.Inventory["Bread"][ingredient];
                }
            }
            else if (IngredientSource.Inventory["Meat"].ContainsKey(ingredient))
            {
                if (!Meat.Contains(IngredientSource.Inventory["Meat"][ingredient]))
                {
                    Meat.Add(IngredientSource.Inventory["Meat"][ingredient]);
                }
                else
                {
                    Meat.Remove(IngredientSource.Inventory["Meat"][ingredient]);
                }

                if (Meat.Count < 1)
                {
                    Meat.Add(IngredientSource.Inventory["Meat"]["None"]);
                }
                else if (Meat[0].ItemName == "None" && Meat.Count > 1)
                {
                    Meat.Remove(IngredientSource.Inventory["Meat"]["None"]);
                }
            }
            else if (IngredientSource.Inventory["Cheese"].ContainsKey(ingredient))
            {
                if (!Cheese.Contains(IngredientSource.Inventory["Cheese"][ingredient]))
                {
                    Cheese.Add(IngredientSource.Inventory["Cheese"][ingredient]);
                }
                else
                {
                    Cheese.Remove(IngredientSource.Inventory["Cheese"][ingredient]);
                }

                if (Cheese.Count < 1)
                {
                    Cheese.Add(IngredientSource.Inventory["Cheese"]["None"]);
                }
                else if (Cheese[0].ItemName == "None" && Cheese.Count > 1)
                {
                    Cheese.Remove(IngredientSource.Inventory["Cheese"]["None"]);
                }
            }
            else if (IngredientSource.Inventory["Topping"].ContainsKey(ingredient))
            {
                if (!Toppings.Contains(IngredientSource.Inventory["Topping"][ingredient]))
                {
                    Toppings.Add(IngredientSource.Inventory["Topping"][ingredient]);
                }
                else
                {
                    Toppings.Remove(IngredientSource.Inventory["Topping"][ingredient]);
                }

                if (Toppings.Count < 1)
                {
                    Toppings.Add(IngredientSource.Inventory["Topping"]["None"]);
                }
                else if (Toppings[0].ItemName == "None" && Toppings.Count > 1)
                {
                    Toppings.Remove(IngredientSource.Inventory["Topping"]["None"]);
                }
            }
        }