public BreakpointDimension Dimension(PositionalContentModel model, PositionalContentItem item, KeyValuePair <string, PositionalContentItemDimension> dimension)
 {
     return(new BreakpointDimension()
     {
         breakpointName = dimension.Key,
         styles = dimension.Value.PositionalStyles(),
         content = ItemContent(model, item, dimension.Value),
         hidden = dimension.Value.Hide
     });
 }
        public object ImageContent(PositionalContentModel model, PositionalContentBreakpoint breakpoint = null, bool showOverriddenOnly = true)
        {
            if (showOverriddenOnly && breakpoint != null && !breakpoint.OverrideContent && !breakpoint.OverrideSettings)
            {
                return(null);
            }

            object output = null;

            IPublishedElement content  = null;
            IPublishedElement settings = null;

            if (breakpoint != null)
            {
                if (breakpoint.HasContent && breakpoint.OverrideContent)
                {
                    content = breakpoint.GetContent(model);
                }
                if (breakpoint.HasSettings && breakpoint.OverrideSettings)
                {
                    settings = breakpoint.GetSetting(model);
                }
            }

            if (model.HasContent && content == null)
            {
                content = model.GetContent();
            }
            if (model.HasSettings && settings == null)
            {
                settings = model.GetSetting();
            }

            foreach (var i in posConImageItems)
            {
                if (i.IsValid(content))
                {
                    output = i.Apply(model, content, settings);
                    AddRefProperty(output);
                    return(output);
                }
            }

            foreach (var i in posConImageItemInternal)
            {
                if (i.IsValid(content))
                {
                    output = i.Apply(model, content, settings);
                    AddRefProperty(output);
                    return(output);
                }
            }

            return(output);
        }
        public object ItemContent(PositionalContentModel model, PositionalContentItem item, PositionalContentItemDimension dimension = null, bool showOverriddenOnly = true)
        {
            if (showOverriddenOnly && dimension != null && !dimension.OverrideContent && !dimension.OverrideSettings)
            {
                return(null);
            }

            object output = null;

            IPublishedElement content  = null;
            IPublishedElement settings = null;

            if (dimension != null)
            {
                if (dimension.HasContent && dimension.OverrideContent)
                {
                    content = dimension.GetContent(model);
                }
                if (dimension.HasSettings && dimension.OverrideSettings)
                {
                    settings = dimension.GetSetting(model);
                }
            }

            if (item.HasContent && content == null)
            {
                content = item.GetContent(model);
            }
            if (item.HasSettings && settings == null)
            {
                settings = item.GetSetting(model);
            }

            foreach (var i in posConContentItems)
            {
                if (i.IsValid(content))
                {
                    output = i.Apply(content, settings);
                    AddRefProperty(output);
                    return(output);
                }
            }

            foreach (var i in posConContentItemsInternal)
            {
                if (i.IsValid(content))
                {
                    output = i.Apply(content, settings);
                    AddRefProperty(output);
                    return(output);
                }
            }

            return(output);
        }
        public object Apply(PositionalContentModel model, IPublishedElement content, IPublishedElement settings)
        {
            var contentModel = content.ToElement <M>();

            if (contentModel != null)
            {
                var output = mapper.Map <V>(contentModel);
                return(output);
            }
            else
            {
                return(null);
            }
        }