protected virtual void BuildDisplayShape(BuildDisplayContext context, TPart instance) { }
async Task <IDisplayResult> IContentPartDisplayDriver.BuildDisplayAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, BuildDisplayContext context) { var part = contentPart as TPart; if (part == null) { return(null); } BuildPrefix(typePartDefinition, context.HtmlFieldPrefix); _typePartDefinition = typePartDefinition; var buildDisplayContext = new BuildPartDisplayContext(typePartDefinition, context); var result = await DisplayAsync(part, buildDisplayContext); _typePartDefinition = null; return(result); }
public async Task BuildDisplayAsync(ContentItem contentItem, BuildDisplayContext context) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); if (contentTypeDefinition == null) { return; } foreach (var displayDriver in _displayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(contentItem, context); if (result != null) { result.Apply(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); } } foreach (var contentTypePartDefinition in contentTypeDefinition.Parts) { var partName = contentTypePartDefinition.Name; var partTypeName = contentTypePartDefinition.PartDefinition.Name; var partActivator = _contentPartFactory.GetTypeActivator(partTypeName); var part = contentItem.Get(partActivator.Type, partName) as ContentPart; if (part != null) { foreach (var displayDriver in _partDisplayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(part, contentTypePartDefinition, context); if (result != null) { result.Apply(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); } } foreach (var contentPartFieldDefinition in contentTypePartDefinition.PartDefinition.Fields) { foreach (var displayDriver in _fieldDisplayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(part, contentPartFieldDefinition, contentTypePartDefinition, context); if (result != null) { result.Apply(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); } } } } } }
public async Task BuildDisplayAsync(ContentItem contentItem, BuildDisplayContext context) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); if (contentTypeDefinition == null) { return; } foreach (var displayDriver in _displayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(contentItem, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, nameof(BuildDisplayAsync)); } } foreach (var contentTypePartDefinition in contentTypeDefinition.Parts) { var partName = contentTypePartDefinition.Name; var partTypeName = contentTypePartDefinition.PartDefinition.Name; var contentType = contentTypePartDefinition.ContentTypeDefinition.Name; var partActivator = _contentPartFactory.GetTypeActivator(partTypeName); var part = contentItem.Get(partActivator.Type, partName) as ContentPart; if (part != null) { var partDisplayDrivers = _contentPartDisplayDriverResolver.GetDisplayModeDrivers(partTypeName, contentTypePartDefinition.DisplayMode()); foreach (var partDisplayDriver in partDisplayDrivers) { try { var result = await partDisplayDriver.BuildDisplayAsync(part, contentTypePartDefinition, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, partDisplayDrivers.GetType().Name, nameof(BuildDisplayAsync)); } } // TODO: This can be removed in a future release as the recommended way is to use ContentOptions. // Iteratate existing driver registrations as multiple drivers maybe not be registered with ContentOptions. foreach (var displayDriver in _partDisplayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(part, contentTypePartDefinition, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, nameof(BuildDisplayAsync)); } } var tempContext = context; // Create a custom ContentPart shape that will hold the fields for dynamic content part (not implicit parts) // This allows its fields to be grouped and templated if (part.GetType() == typeof(ContentPart) && partTypeName != contentTypePartDefinition.ContentTypeDefinition.Name) { var shapeType = context.DisplayType != "Detail" ? "ContentPart_" + context.DisplayType : "ContentPart"; var shapeResult = new ShapeResult(shapeType, ctx => ctx.ShapeFactory.CreateAsync(shapeType, () => new ValueTask <IShape>(new ZoneHolding(() => ctx.ShapeFactory.CreateAsync("Zone"))))); shapeResult.Differentiator(partName); shapeResult.Location("Content"); await shapeResult.ApplyAsync(context); var contentPartShape = shapeResult.Shape; // Make the ContentPart name property available on the shape dynamic dynamicContentPartShape = contentPartShape; dynamicContentPartShape[partTypeName] = part.Content; dynamicContentPartShape["ContentItem"] = part.ContentItem; contentPartShape.Metadata.Alternates.Add(partTypeName); contentPartShape.Metadata.Alternates.Add($"{contentType}__{partTypeName}"); if (context.DisplayType != "Detail") { contentPartShape.Metadata.Alternates.Add($"{partTypeName}_{context.DisplayType}"); contentPartShape.Metadata.Alternates.Add($"{contentType}_{context.DisplayType}__{partTypeName}"); } if (partName != partTypeName) { contentPartShape.Metadata.Alternates.Add($"{contentType}__{partName}"); if (context.DisplayType != "Detail") { contentPartShape.Metadata.Alternates.Add($"{contentType}_{context.DisplayType}__{partName}"); } } context = new BuildDisplayContext(shapeResult.Shape, context.DisplayType, context.GroupId, context.ShapeFactory, context.Layout, context.Updater); } foreach (var contentPartFieldDefinition in contentTypePartDefinition.PartDefinition.Fields) { var fieldDisplayDrivers = _contentFieldDisplayDriverResolver.GetDisplayModeDrivers(contentPartFieldDefinition.FieldDefinition.Name, contentPartFieldDefinition.DisplayMode()); foreach (var fieldDisplayDriver in fieldDisplayDrivers) { try { var result = await fieldDisplayDriver.BuildDisplayAsync(part, contentPartFieldDefinition, contentTypePartDefinition, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, fieldDisplayDriver.GetType().Name, nameof(BuildDisplayAsync)); } } // TODO: This can be removed in a future release as the recommended way is to use ContentOptions. // Iteratate existing driver registrations as multiple drivers maybe not be registered with ContentOptions. foreach (var displayDriver in _fieldDisplayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(part, contentPartFieldDefinition, contentTypePartDefinition, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, nameof(BuildDisplayAsync)); } } } context = tempContext; } } }
public BuildFieldDisplayContext(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, ContentPartFieldDefinition partFieldDefinition, BuildDisplayContext context) : base(context.Shape, context.DisplayType, context.GroupId, context.ShapeFactory, context.Layout, context.Updater) { ContentPart = contentPart; TypePartDefinition = typePartDefinition; PartFieldDefinition = partFieldDefinition; }
protected override void BuildDisplayShape(BuildDisplayContext context) { _itemIds.Add(context.Content.Id); }
public override async Task <IDisplayResult> DisplayAsync(ContentItem model, BuildDisplayContext context) { var httpContext = _httpContextAccessor.HttpContext; var dashboardFeature = httpContext.Features.Get <DashboardFeature>(); // Return if it's not Manage dashboard request if (dashboardFeature == null || !dashboardFeature.IsManageRequest) { return(null); } var results = new List <IDisplayResult>(); var hasPublished = await _contentManager.HasPublishedVersionAsync(model); var hasDraft = model.HasDraft(); var hasEditPermission = await _authorizationService.AuthorizeAsync(httpContext.User, CommonPermissions.EditContent, model); var hasDeletePermission = await _authorizationService.AuthorizeAsync(httpContext.User, CommonPermissions.DeleteContent, model); var hasPublishPermission = await _authorizationService.AuthorizeAsync(httpContext.User, CommonPermissions.PublishContent, model); var dragHandle = Initialize <ContentItemViewModel>("Dashboard_DragHandle", m => { m.ContentItem = model; }).Location("Leading:before"); results.Add(dragHandle); if (hasEditPermission) { var editButton = Initialize <ContentItemViewModel>("Dashboard_EditButton", m => { m.ContentItem = model; }).Location("ActionsMenu:after"); results.Add(editButton); } if (hasDeletePermission) { var deleteButton = Initialize <ContentItemViewModel>("Dashboard_DeleteButton", m => { m.ContentItem = model; }).Location("ActionsMenu:after"); results.Add(deleteButton); } if (hasPublished && hasPublishPermission) { var unpublishButton = Initialize <ContentItemViewModel>("Dashboard_UnpublishButton", m => { m.ContentItem = model; }).Location("ActionsMenu:after"); results.Add(unpublishButton); } if (hasDraft && hasPublishPermission) { var publishButton = Initialize <ContentItemViewModel>("Dashboard_PublishButton", m => { m.ContentItem = model; }).Location("ActionsMenu:after"); results.Add(publishButton); } if (hasDraft && hasEditPermission) { var discardDraftButton = Initialize <ContentItemViewModel>("Dashboard_DiscardDraftButton", m => { m.ContentItem = model; }).Location("ActionsMenu:after"); results.Add(discardDraftButton); } var shapeTag = Initialize <ContentItemViewModel>("DashboardWidget_DetailAdmin__ContentsTags", m => { m.ContentItem = model; }).Location("DetailAdmin", "Tags:10"); results.Add(shapeTag); return(Combine(results.ToArray())); }
public override void Apply(BuildDisplayContext context) { }
public virtual IDisplayResult Display(TStep step, BuildDisplayContext context) { return(Display(step)); }
public override async Task <IDisplayResult> DisplayAsync(ContentOptionsViewModel model, BuildDisplayContext context) { if (await _deploymentPlanService.DoesUserHaveExportPermissionAsync()) { var siteSettings = await _siteService.GetSiteSettingsAsync(); var exportContentToDeploymentTargetSettings = siteSettings.As <ExportContentToDeploymentTargetSettings>(); if (exportContentToDeploymentTargetSettings.ExportContentToDeploymentTargetPlanId != 0) { return(Combine( Dynamic("ExportContentToDeploymentTarget__Button__ContentsBulkActions").Location("BulkActions", "Content:30"), Dynamic("ExportContentToDeploymentTarget_Modal__ContentsBulkActionsDeploymentTarget").Location("BulkActions", "Content:30") )); } } return(null); }
public virtual Task <IDisplayResult> DisplayAsync(TStep step, BuildDisplayContext context) { return(Task.FromResult(Display(step, context))); }
public Task <IDisplayResult> BuildDisplayAsync(DeploymentStep deploymentStep, BuildDisplayContext context) { var step = deploymentStep as TStep; if (step == null) { return(Task.FromResult <IDisplayResult>(null)); } return(DisplayAsync(step, context)); }
public override async Task <IDisplayResult> DisplayAsync(ContentItem contentItem, BuildDisplayContext context) { // We only apply this on the primary content item, which is considered the first call to BuildDisplay. if (_primaryContentRendered) { return(null); } _primaryContentRendered = true; // Do not include Widgets or any display type other than detail. if (context.DisplayType != "Detail" || context.Shape.TryGetProperty(nameof(ContentTypeSettings.Stereotype), out string _)) { return(null); } var aspect = await _contentManager.PopulateAspectAsync <SeoAspect>(contentItem); if (!aspect.Render) { return(null); } if (!String.IsNullOrEmpty(aspect.PageTitle)) { _pageTitleBuilder.SetFixedTitle(new HtmlString(await RenderAsync(aspect.PageTitle, contentItem))); } if (!String.IsNullOrEmpty(aspect.MetaDescription)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "description", Content = await RenderAsync(aspect.MetaDescription, contentItem) }); } if (!String.IsNullOrEmpty(aspect.MetaKeywords)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "keywords", Content = await RenderAsync(aspect.MetaKeywords, contentItem) }); } if (!String.IsNullOrEmpty(aspect.Canonical)) { _resourceManager.RegisterLink(new LinkEntry { Href = aspect.Canonical, Rel = "canonical" }); } if (!String.IsNullOrEmpty(aspect.MetaRobots)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "robots", Content = await RenderAsync(aspect.MetaRobots, contentItem) }); } foreach (var customMetaTag in aspect.CustomMetaTags) { // Generate a new meta entry as the builder is preopulated. _resourceManager.RegisterMeta(new MetaEntry( await RenderAsync(customMetaTag.Name, contentItem), await RenderAsync(customMetaTag.Property, contentItem), await RenderAsync(customMetaTag.Content, contentItem), await RenderAsync(customMetaTag.HttpEquiv, contentItem), await RenderAsync(customMetaTag.Charset, contentItem))); } // OpenGraph. if (!String.IsNullOrEmpty(aspect.OpenGraphType)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:type", Content = await RenderAsync(aspect.OpenGraphType, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphTitle)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:title", Content = await RenderAsync(aspect.OpenGraphTitle, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphDescription)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:description", Content = await RenderAsync(aspect.OpenGraphDescription, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphImage)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:image", Content = await RenderAsync(aspect.OpenGraphImage, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphImageAlt)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:image:alt", Content = await RenderAsync(aspect.OpenGraphImageAlt, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphUrl)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:url", Content = await RenderAsync(aspect.OpenGraphUrl, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphSiteName)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:site_name", Content = await RenderAsync(aspect.OpenGraphSiteName, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphAppId)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "fb:app_id", Content = await RenderAsync(aspect.OpenGraphAppId, contentItem) }); } if (!String.IsNullOrEmpty(aspect.OpenGraphLocale)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "og:locale", Content = await RenderAsync(aspect.OpenGraphLocale, contentItem) }); } // Twitter. if (!String.IsNullOrEmpty(aspect.TwitterCard)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "twitter:card", Content = await RenderAsync(aspect.TwitterCard, contentItem) }); } if (!String.IsNullOrEmpty(aspect.TwitterSite)) { _resourceManager.RegisterMeta(new MetaEntry { Property = "twitter:site", Content = await RenderAsync(aspect.TwitterSite, contentItem) }); } if (!String.IsNullOrEmpty(aspect.TwitterTitle)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "twitter:title", Content = await RenderAsync(aspect.TwitterTitle, contentItem) }); } if (!String.IsNullOrEmpty(aspect.TwitterDescription)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "twitter:description", Content = await RenderAsync(aspect.TwitterDescription, contentItem) }); } if (!String.IsNullOrEmpty(aspect.TwitterImage)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "twitter:image", Content = await RenderAsync(aspect.TwitterImage, contentItem) }); } if (!String.IsNullOrEmpty(aspect.TwitterImageAlt)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "twitter:image:alt", Content = await RenderAsync(aspect.TwitterImageAlt, contentItem) }); } if (!String.IsNullOrEmpty(aspect.TwitterCreator)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "twitter:creator", Content = await RenderAsync(aspect.TwitterCreator, contentItem) }); } if (!String.IsNullOrEmpty(aspect.TwitterUrl)) { _resourceManager.RegisterMeta(new MetaEntry { Name = "twitter:url", Content = await RenderAsync(aspect.TwitterUrl, contentItem) }); } if (!String.IsNullOrEmpty(aspect.GoogleSchema)) { _resourceManager.RegisterHeadScript(new HtmlString($"<script type=\"application/ld+json\">\n{aspect.GoogleSchema}\n</script>")); } return(null); }
public override async Task <IDisplayResult> DisplayAsync(ContentOptionsViewModel model, BuildDisplayContext context) { if (await _deploymentPlanService.DoesUserHavePermissionsAsync()) { return(Combine( Dynamic("AddToDeploymentPlan__Button__ContentsBulkActions").Location("BulkActions", "Content:20"), Dynamic("AddToDeploymentPlan_Modal__ContentsBulkActionsDeploymentPlan").Location("BulkActions", "Content:20") )); } return(null); }
Task <IDisplayResult> IDisplayDriver <ContentItem, BuildDisplayContext, BuildEditorContext, UpdateEditorContext> .BuildDisplayAsync(ContentItem model, BuildDisplayContext context) { var part = model.As <TPart>(); if (part != null) { Prefix = GeneratePrefix(part); return(DisplayAsync(part, context.Updater)); } return(Task.FromResult <IDisplayResult>(null)); }
Task <IDisplayResult> IContentPartDisplayDriver.BuildDisplayAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, BuildDisplayContext context) { var buildDisplayContext = new BuildPartDisplayContext(typePartDefinition, context); return(DisplayAsync(contentPart, buildDisplayContext)); }
Task <IDisplayResult> IContentPartDisplayDriver.BuildDisplayAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, BuildDisplayContext context) { var part = contentPart as TPart; if (part == null) { return(Task.FromResult <IDisplayResult>(null)); } var buildDisplayContext = new BuildPartDisplayContext(typePartDefinition, context); return(DisplayAsync(part, buildDisplayContext)); }
Task <IDisplayResult> IContentFieldDisplayDriver.BuildDisplayAsync(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition, ContentTypePartDefinition typePartDefinition, BuildDisplayContext context) { if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) && !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name)) { return(Task.FromResult(default(IDisplayResult))); } var field = contentPart.Get <TField>(partFieldDefinition.Name); if (field != null) { BuildPrefix(typePartDefinition, partFieldDefinition, context.HtmlFieldPrefix); var fieldDisplayContext = new BuildFieldDisplayContext(contentPart, typePartDefinition, partFieldDefinition, context); _typePartDefinition = typePartDefinition; _partFieldDefinition = partFieldDefinition; var result = DisplayAsync(field, fieldDisplayContext); _typePartDefinition = null; _partFieldDefinition = null; return(result); } return(Task.FromResult(default(IDisplayResult))); }
public virtual DisplayResult BuildDisplay(BuildDisplayContext context) { return(null); }
public override void Apply(BuildDisplayContext context) { var templateShape = context.New.DisplayTemplate(TemplateName: TemplateName, Model: Model, Prefix: Prefix); context.Shape.Zones[Zone].Add(templateShape, Position); }
public void BuildDisplay(BuildDisplayContext context) { }
public virtual void Apply(BuildDisplayContext context) { }
public override Task <IDisplayResult> DisplayAsync(TModel model, BuildDisplayContext context) { var section = GetSection(model); return(DisplayAsync(model, section, context)); }
public Task ApplyAsync(BuildDisplayContext context) { return(ApplyImplementationAsync(context, context.DisplayType)); }
public virtual Task <IDisplayResult> DisplayAsync(TModel model, TSection section, BuildDisplayContext context) { return(DisplayAsync(section, context)); }
private IEnumerable <DriverResultPlacement> ExtractPlacement(DriverResult result, BuildShapeContext context) { if (result is CombinedResult) { foreach (var subResult in ((CombinedResult)result).GetResults()) { foreach (var placement in ExtractPlacement(subResult, context)) { yield return(placement); } } } else if (result is ContentShapeResult) { var contentShapeResult = (ContentShapeResult)result; var placement = context.FindPlacement( contentShapeResult.GetShapeType(), contentShapeResult.GetDifferentiator(), contentShapeResult.GetLocation() ); string zone = placement.Location; string position = String.Empty; // if no placement is found, it's hidden, e.g., no placement was found for the specific ContentType/DisplayType if (placement.Location != null) { var delimiterIndex = placement.Location.IndexOf(':'); if (delimiterIndex >= 0) { zone = placement.Location.Substring(0, delimiterIndex); position = placement.Location.Substring(delimiterIndex + 1); } } var content = _contentManager.New(context.ContentItem.ContentType); dynamic itemShape = CreateItemShape("Content_Edit"); itemShape.ContentItem = content; if (context is BuildDisplayContext) { var newContext = new BuildDisplayContext(itemShape, content, "Detail", "", context.New); BindPlacement(newContext, "Detail", "Content"); contentShapeResult.Apply(newContext); } else { var newContext = new BuildEditorContext(itemShape, content, "", context.New); BindPlacement(newContext, null, "Content"); contentShapeResult.Apply(newContext); } yield return(new DriverResultPlacement { Shape = itemShape.Content, ShapeResult = contentShapeResult, PlacementSettings = new PlacementSettings { ShapeType = contentShapeResult.GetShapeType(), Zone = zone, Position = position, Differentiator = contentShapeResult.GetDifferentiator() ?? String.Empty } }); } }
public virtual Task <IDisplayResult> DisplayAsync(TSection section, BuildDisplayContext context) { return(Task.FromResult(Display(section, context))); }
public override void Apply(BuildDisplayContext context) { ApplyImplementation(context, context.DisplayType); }
public virtual IDisplayResult Display(TSection section, BuildDisplayContext context) { return(Display(section)); }
public virtual void BuildDisplay(BuildDisplayContext context) {}
public async Task BuildDisplayAsync(ContentItem contentItem, BuildDisplayContext context) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); if (contentTypeDefinition == null) { return; } foreach (var displayDriver in _displayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(contentItem, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); } } foreach (var contentTypePartDefinition in contentTypeDefinition.Parts) { var partName = contentTypePartDefinition.Name; var partTypeName = contentTypePartDefinition.PartDefinition.Name; var partActivator = _contentPartFactory.GetTypeActivator(partTypeName); var part = contentItem.Get(partActivator.Type, partName) as ContentPart; if (part != null) { foreach (var displayDriver in _partDisplayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(part, contentTypePartDefinition, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); } } var tempContext = context; // Create a custom ContentPart shape that will hold the fields for dynamic content part (not implicit parts) // This allows its fields to be grouped and templated if (part.GetType() == typeof(ContentPart) && contentTypePartDefinition.PartDefinition.Name != contentTypePartDefinition.ContentTypeDefinition.Name) { var shapeType = context.DisplayType != "Detail" ? "ContentPart_" + context.DisplayType : "ContentPart"; var shapeResult = new ShapeResult(shapeType, ctx => ctx.ShapeFactory.CreateAsync(shapeType, () => Task.FromResult <IShape>(new ZoneHolding(() => ctx.ShapeFactory.CreateAsync("Zone", Arguments.Empty))))); shapeResult.Differentiator(contentTypePartDefinition.PartDefinition.Name); shapeResult.Location("Content"); await shapeResult.ApplyAsync(context); var contentPartShape = shapeResult.Shape; // Make the ContentPart name property available on the shape dynamic dynamicContentPartShape = contentPartShape; dynamicContentPartShape[contentTypePartDefinition.PartDefinition.Name] = part.Content; dynamicContentPartShape["ContentItem"] = part.ContentItem; contentPartShape.Metadata.Alternates.Add(contentTypePartDefinition.PartDefinition.Name); if (context.DisplayType != "Detail") { contentPartShape.Metadata.Alternates.Add($"{contentTypePartDefinition.PartDefinition.Name}_{context.DisplayType}"); } context = new BuildDisplayContext(shapeResult.Shape, context.DisplayType, context.GroupId, context.ShapeFactory, context.Layout, context.Updater); } foreach (var contentPartFieldDefinition in contentTypePartDefinition.PartDefinition.Fields) { foreach (var displayDriver in _fieldDisplayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(part, contentPartFieldDefinition, contentTypePartDefinition, context); if (result != null) { await result.ApplyAsync(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); } } } context = tempContext; } } }