Пример #1
0
        public async Task<dynamic> BuildDisplayAsync(IContent content, string displayType, string groupId)
        {
            if(content == null || content.ContentItem == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(content.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 = content.ContentItem;
            itemShape.Metadata.DisplayType = actualDisplayType;

            var context = new BuildDisplayContext(itemShape, content, actualDisplayType, groupId, _shapeFactory);
            context.Layout = _layoutAccessor.GetLayout();

            await BindPlacementAsync(context, actualDisplayType, stereotype.Value<string>());

            await _handlers.InvokeAsync(handler => handler.BuildDisplayAsync(context), Logger);
            return context.Shape;
        }
Пример #2
0
        public override DisplayResult BuildDisplay(BuildDisplayContext context)
        {
            var testContentPart = context.Content.As<TestContentPartA>();

            if (testContentPart == null)
            {
                return null;
            }

            return Combine(
                // A new shape is created and the properties of the object are bound to it when rendered
                Shape("TestContentPartA", testContentPart).Location("Content"),
                // New shape, no initialization, custom location
                Shape("LowerDoll").Location("Footer"),
                // New shape 
                Shape("TestContentPartA",
                    ctx => ctx.New.TestContentPartA().Creating(_creating++),
                    shape =>
                    {
                        shape.Processing = _processing++;
                        return Task.CompletedTask;
                    })
                    .Location("Content")
                    .Cache("lowerdoll2", cache => cache.During(TimeSpan.FromSeconds(5))),
                // A strongly typed shape model is used and initialized when rendered
                Shape<TestContentPartAShape>(shape => { shape.Line = "Strongly typed shape"; return Task.CompletedTask; })
                    .Location("Content:2"),
                // Cached shape
                Shape("LowerDoll")
                    .Location("/Footer")
                    .Cache("lowerdoll", cache => cache.During(TimeSpan.FromSeconds(5)))
                );
        }
Пример #3
0
 public override void Apply(BuildDisplayContext context)
 {
     foreach (var result in _results)
     {
         result.Apply(context);
     }
 }
 public Task BuildDisplayAsync(BuildDisplayContext context)
 {
     return _drivers.InvokeAsync(async driver => {
         var result = await driver.BuildDisplayAsync(context);
         if (result != null)
             result.Apply(context);
     }, Logger);
 }
Пример #5
0
        public Task BuildDisplayAsync(BuildDisplayContext context)
        {
            _drivers.Invoke(driver => {
                var result = driver.BuildDisplay(context);
                if (result != null)
                    result.Apply(context);
            }, Logger);

            return Task.CompletedTask;
        }
Пример #6
0
 public override void Apply(BuildDisplayContext context)
 {
     ApplyImplementation(context, context.DisplayType);
 }
Пример #7
0
 public virtual void Apply(BuildDisplayContext context) { }