コード例 #1
0
ファイル: PreParsedRecipe.cs プロジェクト: ssargent/cooking
        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);
        }
コード例 #2
0
ファイル: MMFRecipeParser.cs プロジェクト: ssargent/cooking
        private RecipeLine FindPreviousIngredient(RecipeLine line)
        {
            while (line.Previous != null)
            {
                line = line.Previous;

                if (line.DataType == RecipeDataType.Ingredients)
                    return line;
            }

            return null;
        }
コード例 #3
0
ファイル: MMFRecipeParser.cs プロジェクト: ssargent/cooking
 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;
         }
     }
 }