Esempio n. 1
0
        public static ICarouselColumn ToCarouselColumn(this ICarouselColumn self)
        {
            if (self.Text == null)
            {
                throw new InvalidOperationException("The text cannot be null.");
            }

            CarouselColumn carouselColumn = self as CarouselColumn;

            if (carouselColumn == null)
            {
                carouselColumn = new CarouselColumn()
                {
                    ThumbnailUrl = self.ThumbnailUrl,
                    Title        = self.Title,
                    Text         = self.Text,
                };
            }

            if (self.Actions == null)
            {
                throw new InvalidOperationException("The actions cannot be null.");
            }

            carouselColumn.Actions = self.Actions.ToTemplateAction().ToArray();

            return(carouselColumn);
        }
Esempio n. 2
0
        private static CarouselColumn Convert(ICarouselColumn column)
        {
            if (column.Text == null)
            {
                throw new InvalidOperationException("The text cannot be null.");
            }

            if (!(column is CarouselColumn carouselColumn))
            {
                carouselColumn = new CarouselColumn()
                {
                    ThumbnailUrl = column.ThumbnailUrl,
                    Title        = column.Title,
                    Text         = column.Text,
                };
            }

            if (column.Actions == null)
            {
                throw new InvalidOperationException("The actions cannot be null.");
            }

            carouselColumn.Actions = TemplateAction.Convert(column.Actions);

            return(carouselColumn);
        }
        internal static CarouselTemplate Convert(ICarouselTemplate template)
        {
            if (!(template is CarouselTemplate carouselTemplate))
            {
                carouselTemplate = new CarouselTemplate();
            }

            if (template.Columns == null)
            {
                throw new InvalidOperationException("The columns cannot be null.");
            }

            carouselTemplate.Columns = CarouselColumn.Convert(template.Columns);

            return(carouselTemplate);
        }