public void AddLine(RecipeLine line) { if (String.IsNullOrEmpty(line.Data.Trim())) line.IsEmpty = true; if (line.IsEmpty && PreviousLine != null && PreviousLine.IsEmpty) return; if (Lines.Count > 0) { line.Previous = Lines[Lines.Count - 1]; Lines[Lines.Count - 1].Next = line; PreviousLine = line.Previous; } Lines.Add(line); }
private RecipeLine FindPreviousIngredient(RecipeLine line) { while (line.Previous != null) { line = line.Previous; if (line.DataType == RecipeDataType.Ingredients) return line; } return null; }
private void CategorizeLine(RecipeLine line, RecipeStateMachine stateMachine) { if (line.IsEmpty) line.DataType = RecipeDataType.NotNeeded; else { switch (stateMachine.CurrentState) { case MMFRecipeStates.StartingSection: line.DataType = RecipeDataType.Unknown; break; case MMFRecipeStates.TitleSection: line.DataType = RecipeDataType.Title; break; case MMFRecipeStates.IngredientsSection: line.DataType = RecipeDataType.Ingredients; break; case MMFRecipeStates.DescriptionSection: line.DataType = RecipeDataType.Instructions; break; } } }