📄
src/JsonLdRecipeParser/InstructionSection.cs
using System; using System.Linq; using JsonLdRecipeParser.Json; namespace JsonLdRecipeParser; public class InstructionSection { public string? Name { get; set; } public Instruction[] Instructions { get; set; } = []; internal static InstructionSection From(RecipeInstruction instruction) => instruction.Value switch { HowToStep { Text: string text } step => new() { Instructions = [new() { Name = step.Name, Text = text }] }, ItemList list => new() { Name = list.Name, Instructions = list.ItemListElement is null ? [] : [.. list.ItemListElement.Select(Instruction.From)], }, string i => new() { Instructions = [new() { Text = i }] }, _ => throw new Exception(), }; }