コード例 #1
0
        public static RecipePart FromRecipePart(IRecipePart recipePart)
        {
            RecipePart r = new RecipePart
            {
                Name = recipePart.Name,
                PreparationMethod  = Tag.FromTag(recipePart.PreparationMethod),
                PreparationSeconds = (int)recipePart.PreparationTime.TotalSeconds,
                CookSeconds        = (int)recipePart.CookTime.TotalSeconds,
                ChillSeconds       = (int)recipePart.ChillTime.TotalSeconds,
                Temperature        = recipePart.Temperature,
                Ingredients        =
                    recipePart.Ingredients
                    .Select <IIngredientDetail, IngredientDetail>(IngredientDetail.FromIngredientDetail)
                    .Where(i => !string.IsNullOrWhiteSpace(i.Amount) || !string.IsNullOrWhiteSpace(i.Ingredient) || !string.IsNullOrWhiteSpace(i.Preparation) || !string.IsNullOrWhiteSpace(i.Quantity))
                    .ToArray(),
                Instructions = new [] { recipePart.Instructions },
            };

            if (recipePart.Comments != null)
            {
                r.Comments = recipePart.Comments.Select <IComment, Comment>(Comment.FromComment).ToArray();
            }
            return(r);
        }
コード例 #2
0
ファイル: RecipePart.cs プロジェクト: jeremyrsellars/recipe
 public static RecipePart FromRecipePart(IRecipePart recipePart)
 {
     RecipePart r = new RecipePart
      {
     Name = recipePart.Name,
     PreparationMethod = Tag.FromTag (recipePart.PreparationMethod),
     PreparationSeconds = (int)recipePart.PreparationTime.TotalSeconds,
     CookSeconds = (int)recipePart.CookTime.TotalSeconds,
     ChillSeconds = (int)recipePart.ChillTime.TotalSeconds,
     Temperature = recipePart.Temperature,
     Ingredients =
        recipePart.Ingredients
           .Select<IIngredientDetail,IngredientDetail>(IngredientDetail.FromIngredientDetail)
           .Where(i => !string.IsNullOrWhiteSpace (i.Amount) || !string.IsNullOrWhiteSpace (i.Ingredient) || !string.IsNullOrWhiteSpace (i.Preparation) || !string.IsNullOrWhiteSpace (i.Quantity))
           .ToArray (),
     Instructions = new [] {recipePart.Instructions},
      };
      if (recipePart.Comments != null)
     r.Comments = recipePart.Comments.Select<IComment,Comment>(Comment.FromComment).ToArray ();
      return r;
 }