public static BlockType GetBlockType(SlideBlock block) { switch (block) { case YoutubeBlock _: return(BlockType.YouTube); case CodeBlock _: return(BlockType.Code); case ImageGalleryBlock _: return(BlockType.GalleryImages); case IncludeCodeBlock _: return(BlockType.IncludeCode); case IncludeImageGalleryBlock _: return(BlockType.IncludeImageGallery); case IncludeMarkdownBlock _: return(BlockType.IncludeMarkdown); case MarkdownBlock _: return(BlockType.Markdown); case TexBlock _: return(BlockType.Tex); case HtmlBlock _: return(BlockType.Html); case SpoilerBlock _: return(BlockType.Spoiler); case FillInBlock _: return(BlockType.TextQuestion); case ChoiceBlock _: return(BlockType.ChoiceQuestion); case MatchingBlock _: return(BlockType.MatchQuestion); case OrderingBlock _: return(BlockType.OrderQuestion); case IsTrueBlock _: return(BlockType.IsTrueQuestion); case CsProjectExerciseBlock _: return(BlockType.CsProjectExercise); case SingleFileExerciseBlock _: return(BlockType.SingleFileExercise); case UniversalExerciseBlock _: return(BlockType.UniversalExercise); default: throw new Exception("Unknown slide block " + block); } }
/// <summary> /// Building slide and blocks, fill properties, initialize some values. Any work we need to do before work with slide. /// </summary> public virtual void BuildUp(SlideLoadingContext context) { Meta?.FixPaths(context.SlideFile); Info = new SlideInfo(context.Unit, context.SlideFile); if (Blocks == null) { Blocks = new SlideBlock[0]; } /* Validate block types. We should do it before building up blocks */ CheckBlockTypes(); /* ... and build blocks */ var slideLoadingContext = new SlideBuildingContext(context, this); Blocks = Blocks.SelectMany(b => b.BuildUp(slideLoadingContext, ImmutableHashSet <string> .Empty)).ToArray(); DefineBlockTypes(); }