public void AddToStock(IIngredient ingredient, Measure measure, double quantity) { double factor = measure.GetEquivalence(ingredient.PackingMeasure, ingredient); quantity *= factor; var ingStock = this.CurrentStock.SingleOrDefault(c => c.Ingredient == ingredient); if (ingStock == null) { ingStock = new IngredientStock { Ingredient = ingredient, Quantity = quantity }; this.CurrentStock.Add(ingStock); } else { ingStock.Quantity += quantity; } if (ingStock.Quantity < 0) { _notifier.Notify("Stock", "La cantidad de un ingrediente en stock NO puede ser menor a cero!", Severity.Warning); } }
public double GetEquivalence(Measure measureTo, IIngredient ingredient) { double factor; if (this.Equals(measureTo)) { factor = 1.0; } else { var equiv = Equivalences.SingleOrDefault(e => e.From == this && e.To == measureTo && e.Ingredient == ingredient); if (equiv == null) { //pruebo la equivalencia opuesta equiv = Equivalences.SingleOrDefault(e => e.From == measureTo && e.To == this && e.Ingredient == ingredient); if (equiv == null) { _notifier.Notify("Equivalence", $"Equivalencia inexistente entre {this.Name} y {measureTo.Name}!", Severity.Error); return(0.0); } factor = 1.0 / equiv.Factor; //invierto la equivalencia } else { factor = equiv.Factor; } } return(factor); }
public void OnIngredientAdd(ISubject subject, IIngredient ingredient) { for (var i = 0; i < _dishEvents.onDishAddIngredient.Count; ++i) { _dishEvents.onDishAddIngredient[i].TryInvoke(ingredient.GetIngredientType()); } }
public void AddIngredient(int ingredientId, IIngredient ingredient) { Validator.ValidateIntRange(ingredientId, 0, int.MaxValue, IdCannotBeNegativeNumber); Validator.ValidateNull(ingredient, string.Format(CannotAddNullObject, nameof(ingredient))); this.ingredients.Add(ingredientId, ingredient); }
public void VisitIngredients(IIngredient ingredient) { if (ingredient.HealthRating == HealthRating.NotRated || ingredient.Calories == 0) { return; } string padding = ""; if (string.IsNullOrEmpty(ingredient.IngredientName)) { Console.WriteLine("--- Item {0} ---", ingredient.GetType().Name); } else { Console.WriteLine(" --- Ingredient {0} ---", ingredient.IngredientName); padding = " "; } Console.WriteLine(padding + "Health Rating: {0}", ingredient.HealthRating); Console.WriteLine(padding + "Calories: {0}", ingredient.Calories); Console.WriteLine(padding + "Carbs: {0}", ingredient.Carbs); Console.WriteLine(padding + "Protein: {0}", ingredient.Protein); Console.WriteLine(); }
public void OnIngredientAdd(ISubject subject, IIngredient ingredient) { var sideDish = subject as Dish; if (sideDish != null) { for (var i = 0; i < _sideDishesLeft.Count; ++i) { if (sideDish == _sideDishesLeft[i]) { if (_debugLog) { Debug.Log(sideDish + " found"); } for (var j = 0; j < _sideDishesMeshIngredientTypes.Count; ++j) { if (_sideDishesMeshIngredientTypes[j] == ingredient.GetIngredientType()) { if (_debugLog) { Debug.Log(ingredient + " is one of the meshes"); } _sideDishMeshesToEnable[i].Add(_sideDishMeshes[j]); _sideDishesMeshIngredientTypes.RemoveAt(j); _sideDishMeshes.RemoveAt(j); break; } } break; } } } }
protected void InformObserversAddIngredient(IIngredient ingredient) { for (var i = 0; i < _observers.Count; ++i) { _observers[i].OnIngredientAdd(this, ingredient); } }
public void AddIngredient(IIngredient ingredient) { if (ingredient == null) throw new ArgumentNullException ("ingredient"); m_list.Add (ingredient); }
public static void Main(string[] args) { Chef chef = new Chef(); IIngredient[] list = new IIngredient[] { new Carrot(), new Potato() }; chef.Cook(list); }
public static void Postfix(ITechData data, ref List <TooltipIcon> icons) { if (data == null) { return; } int ingredientCount = data.ingredientCount; for (int i = 0; i < ingredientCount; i++) { IIngredient ingredient = data.GetIngredient(i); TechType techType = ingredient.techType; if (!KnownTech.Contains(techType) && PDAScanner.ContainsCompleteEntry(techType)) { KnownTech.Add(techType); continue; } if (!CrafterLogic.IsCraftRecipeUnlocked(techType)) { TooltipIcon icon = icons.Find((TooltipIcon) => TooltipIcon.sprite == SpriteManager.Get(techType) && TooltipIcon.text.Contains(Language.main.GetOrFallback(TooltipFactory.techTypeIngredientStrings.Get(techType), techType))); if (icons.Contains(icon)) { icons.Remove(icon); var tooltipIcon = new TooltipIcon() { sprite = SpriteManager.Get(TechType.None), text = Main.config.UnKnownTitle }; icons.Add(tooltipIcon); } } } }
public void ContainerResolvesIngredientThroughExtensionMethod() { var context = new XmlApplicationContext("sauce.xml"); IIngredient ingredient = context.Resolve <IIngredient>(); Assert.IsAssignableFrom <SauceBéarnaise>(ingredient); }
public Task <bool> AddIngredient(Guid recipeId, IIngredient ingredient) { return(Task.Run(() => { using var context = new HomeAppDbContext(myDbOptions); DbProduct product = context.Products.FirstOrDefault(p => p.Id.Equals(ingredient.ProductId)); if (product == null) { return false; } DbRecipe recipe = context.Recipes.FirstOrDefault(p => p.Id.Equals(recipeId)); if (product == null) { return false; } context.Ingredients.AddAsync(new DbIngredient { Product = product, Recipe = recipe, UnitQuantity = ingredient.UnitQuantity, UnitQuantityType = ingredient.UnitQuantityType }); context.SaveChanges(); return true; })); }
public static bool ConsumeResources(TechType techType) { if (!IsCraftRecipeFulfilled(techType)) { ErrorMessage.AddWarning(Language.main.Get("DontHaveNeededIngredients")); return(false); } var itemsContainers = FindAllItemsContainersInRange(); ITechData techData = CraftData.Get(techType, false); if (techData == null) { return(false); } int i = 0; int ingredientCount = techData.ingredientCount; while (i < ingredientCount) { IIngredient ingredient = techData.GetIngredient(i); TechType techType2 = ingredient.techType; int j = 0; int amount = ingredient.amount; while (j < amount) { DestroyItemInContainers(techType2, itemsContainers); uGUI_IconNotifier.main.Play(techType2, uGUI_IconNotifier.AnimationType.To, null); j++; } i++; } return(true); }
public void RemoveIngredient(IIngredient ingredient) { Validator.ValidateNull(ingredient, $"The ingredient is null!"); int index = this.Ingredients.FindIndex(item => item.Igredient.Name.Equals(ingredient.Name)); this.Ingredients.RemoveAt(index); }
public static bool IsCraftRecipeFulfilled(TechType techType) { if (Inventory.main == null) { return(false); } if (!GameModeUtils.RequiresIngredients()) { return(true); } var itemContainers = FindAllItemsContainersInRange(); ITechData techData = CraftData.Get(techType, false); if (techData != null) { int i = 0; int ingredientCount = techData.ingredientCount; while (i < ingredientCount) { IIngredient ingredient = techData.GetIngredient(i); if (GetTotalPickupCount(ingredient.techType, itemContainers) < ingredient.amount) { return(false); } i++; } return(true); } return(false); }
/// <summary> /// Добавление нового ингредиента /// </summary> /// <param name="newIngredient"> Новый ингредиент</param> /// <returns>Возвращает true, если добавление прошло успешно</returns> public bool AddNewIngredient(IIngredient newIngredient) { if (Context.context.Ingredients.Select(x => x.NameIngredient).Contains(newIngredient.NameIngredient)) { return(false); } else { var ing = Context.context.Ingredients.Add(new ModelDB.Ingredient() { NameIngredient = newIngredient.NameIngredient, IDTypeIngredient = newIngredient.TypeIngredient.IDTypeIngredient, Protein = (float)newIngredient.Protein, Fat = (float)newIngredient.Fat, Carbohydrate = (float)newIngredient.Carbohydrate }); Context.context.Products.Add(new Product() { Price = newIngredient.StartingPrice, Mass = (float)newIngredient.MassInKg, BeginDate = newIngredient.RecordDate, IDIngredient = ing.IDIngredient, IDSubdivision = newIngredient.Subdivision.IDSubdivision }); Context.context.SaveChanges(); Context.context.Dispose(); Context.context = new DB_MenuEntities(); return(true); } }
/// <summary> /// Добавление ингредиента в репозиторий /// </summary> /// <param name="NewIngredient">Добавляемый ингредиент</param> public void AddIngredientInRepository(IIngredient NewIngredient) { if (NewIngredient == null) { throw new ArgumentNullException("newIngredient"); } _IngredientController.Add(NewIngredient); }
public RecipesController(IIngredient ingredient, IInstruction instruction, IRecipe recipe, ISavedRecipe savedRecipe, SignInManager <ApplicationUser> signInManager) { _Ingredient = ingredient; _Instruction = instruction; _Recipe = recipe; _SavedRecipe = savedRecipe; _SignInManager = signInManager; }
public void Assign(IIngredient ingredient) { Id = ingredient.Id; ProductId = ingredient.ProductId; RecipeId = ingredient.RecipeId; Amount = ingredient.Amount; UnitId = ingredient.UnitId; }
public static Ingredient FromIngredient(IIngredient ingredient) { Ingredient i = new Ingredient { Name = ingredient.Name, }; return i; }
private void DrawIngredientItem(object sender, DrawItemEventArgs e) { ingredientStamp.ImageWidth = 22; IIngredient ingredient = ((sender as ListControl)?.DataSource as BindingSource)?[e.Index] as IIngredient; ingredientStamp.DrawItem(e, ingredient?.Name ?? "", ingredient?.Image); }
public HomeController(IRecipe recipe, IInstruction instructions, IIngredient ingredient, IComment comment, ISavedRecipe savedRecipe) { _Recipe = recipe; _Instruction = instructions; _Ingredient = ingredient; _Comment = comment; _SavedRecipe = savedRecipe; }
public static Ingredient FromIngredient(IIngredient ingredient) { Ingredient i = new Ingredient { Name = ingredient.Name, }; return(i); }
public void ToString_ReturnsCorrectStringEasyFraction() { this.amount = 0.75; this.ingredient = new Ingredient(this.amount, this.foodItem); var expected = String.Format("3/4 - {0}", this.ingredient.Name); var actual = this.ingredient.ToString(); Assert.IsTrue(StringAssert.Equals(expected, actual)); }
/// <summary> /// Initializes a new instance of the <see cref="RecipeComponent"/> class. /// </summary> public RecipeComponent(IIngredient ingredient) { _recipeComponent = new RecipeComponentDb { Ingredient = (ingredient as Ingredient).UnwrapDataObject(), Amount = 0, Unit = default(UnitTypes) }; }
public void ToString_ReturnsCorrectStringAnotherHardFraction() { this.amount = 2.115; this.ingredient = new Ingredient(this.amount, this.foodItem); var expected = String.Format("2 23/200 - {0}", this.ingredient.Name); var actual = this.ingredient.ToString(); Assert.IsTrue(StringAssert.Equals(expected, actual)); }
public void AddIngredient(IIngredient ingredient) { if (ingredient == null) { throw new ArgumentNullException("ingredient"); } m_list.Add(ingredient); }
public void ToString_ReturnsCorrectStringNaturalNumber() { this.amount = 1; this.ingredient = new Ingredient(this.amount, this.foodItem); var expected = String.Format("1 - {0}", this.ingredient.Name); var actual = this.ingredient.ToString(); Assert.IsTrue(StringAssert.Equals(expected, actual)); }
public Order(Client client, IIngredient salad, IDessert dessert, IDrink drink) { Client = client; Salad = salad; Dessert = dessert; Drink = drink; Client.Order = this; }
public Breading(IIngredient ingredient) { if (ingredient == null) { throw new ArgumentNullException("ingredient"); } this.ingredient = ingredient; }
public void ContainerResolvesIngredientToSauceBéarnaise() { var container = new UnityContainer(); container.RegisterType <IIngredient, SauceBéarnaise>(); IIngredient ingredient = container.Resolve <IIngredient>(); Assert.IsAssignableFrom <SauceBéarnaise>(ingredient); }
public void ContainerResolvesIngredientToSauceBéarnaise() { var catalog = new TypeCatalog(typeof(Ploeh.Samples.Menu.Mef.Attributed.Unmodified.Abstract.SauceBéarnaise)); var container = new CompositionContainer(catalog); IIngredient ingredient = container.GetExportedValue <IIngredient>(); Assert.IsAssignableFrom <SauceBéarnaise>(ingredient); }
private void Init(IIngredient ingredient, Atlas.Sprite sprite, bool first, bool last) { this.ingredient = ingredient; bool mainIcon = ingredient == null; var quickSlots = GameObject.FindObjectOfType <uGUI_QuickSlots>(); var bgSprite = first ? quickSlots.spriteLeft : last ? quickSlots.spriteRight : quickSlots.spriteCenter; (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bgSprite.rect.width); (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, bgSprite.rect.height); layout = gameObject.AddComponent <LayoutElement>(); layout.minWidth = bgSprite.rect.width; layout.minHeight = bgSprite.rect.height; background = gameObject.AddComponent <Image>(); background.color = new Color(1, 1, 1, Mod.config.BackgroundAlpha); background.raycastTarget = false; background.material = quickSlots.materialBackground; background.sprite = bgSprite; icon = new GameObject("Icon").AddComponent <uGUI_ItemIcon>(); icon.transform.SetParent(transform, false); icon.SetForegroundSprite(sprite); if (mainIcon) { icon.SetSize(Width, Width); } else { icon.SetSize(IconWidth, IconWidth); } icon.rectTransform.anchorMin = new Vector2(0.5f, 0.5f); icon.rectTransform.anchorMax = new Vector2(0.5f, 0.5f); icon.rectTransform.pivot = new Vector2(0.5f, 0.5f); icon.rectTransform.anchoredPosition = new Vector2(0, 0); icon.raycastTarget = false; if (!mainIcon) { text = ModUtils.InstantiateNewText("Text", transform); RectTransformExtensions.SetSize(text.rectTransform, Width, Width); text.rectTransform.anchorMin = new Vector2(0.5f, 0); text.rectTransform.anchorMax = new Vector2(0.5f, 0); text.rectTransform.pivot = new Vector2(0.5f, 0); text.rectTransform.anchoredPosition = new Vector2(0, 0); text.alignment = TextAnchor.LowerCenter; text.fontSize = Mod.config.FontSize; text.raycastTarget = false; ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorGoodColorblind : IngredientColorGood, out goodColor); ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorBadColorblind : IngredientColorBad, out badColor); } UpdateText(); }
/// <summary> /// Determines if the ingredient is available from the partner /// </summary> public bool IngredientIsEnabled(IIngredient ingredient) { if(ingredient == null) { throw new ArgumentNullException("ingredient"); } var ingType = ingredient is Fermentable ? IngredientType.Fermentable : ingredient is Hop ? IngredientType.Hop : ingredient is Yeast ? IngredientType.Yeast : IngredientType.Adjunct; return this.Ingredients.Any(x => x.IngredientTypeId == (int)ingType && x.IngredientId == ingredient.IngredientId); }
private static void Cut(IIngredient ingredient) { Console.WriteLine("{0} is cut", ingredient.GetType().Name); }
public IngredientView(IIngredient ingredient) { Assign(ingredient); }
public DbIngredient(IIngredient ingredient) { Assign(ingredient); }
/// <summary> /// Sets the Ingredient /// </summary> public void SetIngredient(IIngredient ingredient) { this.Hop = (Hop)ingredient; }
/// <summary> /// Sets the Ingredient /// </summary> public void SetIngredient(IIngredient ingredient) { this.Yeast = (Yeast)ingredient; }
/// <summary> /// Sets the Ingredient /// </summary> public void SetIngredient(IIngredient ingredient) { this.Fermentable = (Fermentable)ingredient; }
public CaesarSalad() { this.extra = new NullIngredient(); }
public void Add(IIngredient ingredient) { this.Ingredients.Add(ingredient); }
public RecipeView(IRecipe recipe, IIngredient[] ingredient) { Assign(recipe); Ingredients = new IngredientCollectionView(ingredient); }
/// <summary> /// Sets the Ingredient /// </summary> public void SetIngredient(IIngredient ingredient) { this.MashStep = (MashStep)ingredient; }
/// <summary> /// Sets the Ingredient /// </summary> public void SetIngredient(IIngredient ingredient) { this.Adjunct = (Adjunct)ingredient; }
private static void Peel(IIngredient ingredient) { Console.WriteLine("{0} is peeled", ingredient.GetType().Name); }