private PreviewArea CreatePreviewArea(PreviewDisplayOption previewDisplayOption, ContentReference contentReference)
        {
            var item = new ContentAreaItem
            {
                ContentLink = contentReference
            };

            var contentArea = _websiteDependencies.ContextResolver.AddContentAreaItem(new ContentArea(), item);

            var areaModel = new PreviewArea
            {
                ContentArea = contentArea,
                Supported   = previewDisplayOption.IsSupported,
                AreaTag     = previewDisplayOption.Tag,
                AreaName    = previewDisplayOption.Name,
            };

            return(areaModel);
        }
示例#2
0
        private PreviewArea CreatePreviewArea(PreviewDisplayOption previewDisplayOption)
        {
            var contentArea = new ContentArea();
            var item        = new ContentAreaItem
            {
                ContentLink = currentContent.ContentLink
            };

            contentArea.Items.Add(item);

            var areaModel = new PreviewArea
            {
                ContentArea = contentArea,
                Supported   = previewDisplayOption.IsSupported,
                AreaTag     = previewDisplayOption.Tag,
                AreaName    = previewDisplayOption.Name,
            };

            return(areaModel);
        }
        private IEnumerable <PreviewArea> GetSupportedPreviewAreas(IContent content)
        {
            var previewModels = new List <PreviewArea>();

            foreach (var displayOption in _displayOptions)
            {
                var isSupported = IsTagSupported(content, displayOption.Tag);
                if (!isSupported)
                {
                    continue;
                }

                var previewDisplayOption =
                    new PreviewDisplayOption {
                    Tag = displayOption.Tag, Name = displayOption.Name,
                };

                var previewArea = CreatePreviewArea(previewDisplayOption, content.ContentLink);
                previewModels.Add(previewArea);
            }

            return(previewModels);
        }