/// <summary> /// A IPageModuleDisplayModelMapper class handles the mapping from /// a display model to a data model. /// /// The mapper supports DI which gives you flexibility in what data /// you want to include in the display model and how you want to /// map it. Mapping is done in batch to improve performance when /// the same block type is used multiple times on a page. /// </summary> public Task MapAsync( PageBlockTypeDisplayModelMapperContext <ContentSectionDataModel> context, PageBlockTypeDisplayModelMapperResult <ContentSectionDataModel> result ) { foreach (var input in context.Items) { var output = new ContentSectionDisplayModel(); output.HtmlText = new HtmlString(input.DataModel.HtmlText); output.Title = input.DataModel.Title; result.Add(input, output); } return(Task.CompletedTask); }
/// <summary> /// A IPageModuleDisplayModelMapper class handles the mapping from /// a display model to a data model. /// /// The mapper supports DI which gives you flexibility in what data /// you want to include in the display model and how you want to /// map it. Mapping is done in batch to improve performance when /// the same block type is used multiple times on a page. /// </summary> public Task <IEnumerable <PageBlockTypeDisplayModelMapperOutput> > MapAsync( IReadOnlyCollection <PageBlockTypeDisplayModelMapperInput <ContentSectionDataModel> > inputCollection, PublishStatusQuery publishStatus ) { var results = new List <PageBlockTypeDisplayModelMapperOutput>(inputCollection.Count); foreach (var input in inputCollection) { var output = new ContentSectionDisplayModel(); output.HtmlText = new HtmlString(input.DataModel.HtmlText); output.Title = input.DataModel.Title; results.Add(input.CreateOutput(output)); } return(Task.FromResult(results.AsEnumerable())); }