public void Apply(BuildDisplayContext context) { foreach (var result in _results) { result.Apply(context); } }
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; }
public Task BuildDisplayAsync(ContentItem model, BuildDisplayContext context) { return _displayDrivers.InvokeAsync(async contentDisplay => { var result = await contentDisplay.BuildDisplayAsync(model, context); if (result != null) result.Apply(context); }, Logger); }
public Task BuildDisplayAsync(ContentItem model, BuildDisplayContext context) { return Process(model, (part, fieldName) => _displayDrivers.InvokeAsync(async contentDisplay => { var result = await contentDisplay.BuildDisplayAsync(fieldName, part, context); if (result != null) result.Apply(context); }, Logger) ); }
public async Task BuildDisplayAsync(ContentItem model, BuildDisplayContext context) { foreach (var displayDriver in _displayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(model, 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) { // Optimized implementation for display // For each field on the content item, invoke all IContentFieldDisplayDriver instances var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); if(contentTypeDefinition == null) { return; } var partInfos = _contentPartDrivers.Select(x => x.GetPartInfo()).ToDictionary(x => x.PartName); foreach (var contentTypePartDefinition in contentTypeDefinition.Parts) { var partName = contentTypePartDefinition.PartDefinition.Name; var partType = partInfos.ContainsKey(partName) ? partInfos[partName].Factory(contentTypePartDefinition).GetType() : null; var part = contentItem.Get(partType ?? typeof(ContentPart), partName) as ContentPart; foreach (var contentPartFieldDefinition in contentTypePartDefinition.PartDefinition.Fields) { var fieldName = contentPartFieldDefinition.Name; foreach (var displayDriver in _displayDrivers) { try { var result = await displayDriver.BuildDisplayAsync(fieldName, part, contentPartFieldDefinition, context); if (result != null) { result.Apply(context); } } catch (Exception ex) { InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); } } } } }
public async Task<dynamic> BuildDisplayAsync(ContentItem contentItem, IUpdateModel updater, string displayType, string groupId) { if(contentItem == null) { throw new ArgumentNullException(nameof(contentItem)); } var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); var stereotype = contentTypeDefinition.Settings.ToObject<ContentTypeSettings>().Stereotype; var actualDisplayType = string.IsNullOrEmpty(displayType) ? "Detail" : displayType; var actualShapeType = stereotype ?? "Content"; // _[DisplayType] is only added for the ones different than Detail if (actualDisplayType != "Detail") { actualShapeType = actualShapeType + "_" + actualDisplayType; } dynamic itemShape = CreateContentShape(actualShapeType); itemShape.ContentItem = contentItem; itemShape.Metadata.DisplayType = actualDisplayType; var context = new BuildDisplayContext( itemShape, actualDisplayType, groupId, _shapeFactory, _layoutAccessor.GetLayout(), updater ); await BindPlacementAsync(context); await _handlers.InvokeAsync(handler => handler.BuildDisplayAsync(contentItem, context), Logger); return context.Shape; }
public async Task<dynamic> BuildDisplayAsync(ContentItem contentItem, string displayType, string groupId) { if(contentItem == null) { throw new ArgumentNullException(nameof(contentItem)); } var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); JToken stereotype; if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype)) { stereotype = "Content"; } var actualShapeType = stereotype.Value<string>(); var actualDisplayType = string.IsNullOrWhiteSpace(displayType) ? "Detail" : displayType; dynamic itemShape = CreateContentShape(actualShapeType); itemShape.ContentItem = contentItem; itemShape.Metadata.DisplayType = actualDisplayType; var context = new BuildDisplayContext( itemShape, actualDisplayType, groupId, _shapeFactory, _layoutAccessor.GetLayout() ); await BindPlacementAsync(context); await _handlers.InvokeAsync(handler => handler.BuildDisplayAsync(contentItem, context), Logger); return context.Shape; }
Task<IDisplayResult> IContentPartDisplayDriver.BuildDisplayAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, BuildDisplayContext context) { var buildDisplayContext = new BuildPartDisplayContext(typePartDefinition, context); return DisplayAsync(contentPart, buildDisplayContext); }
public void Apply(BuildDisplayContext context) { ApplyImplementation(context, context.DisplayType); }
Task <IDisplayResult> IDisplayDriver <TModel> .BuildDisplayAsync(TModel model, BuildDisplayContext context) { return(DisplayAsync(model, context.Updater)); }
public BuildPartDisplayContext(ContentTypePartDefinition typePartDefinition, BuildDisplayContext context) : base(context.Shape, context.DisplayType, context.GroupId, context.ShapeFactory, context.Layout, context.Updater) { TypePartDefinition = typePartDefinition; }