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

            ConfirmTemplate confirmTemplate = self as ConfirmTemplate;

            if (confirmTemplate == null)
            {
                confirmTemplate = new ConfirmTemplate()
                {
                    Text = self.Text
                };
            }

            if (self.OkAction == null)
            {
                throw new InvalidOperationException("The ok action cannot be null.");
            }

            if (self.CancelAction == null)
            {
                throw new InvalidOperationException("The cancel action cannot be null.");
            }

            confirmTemplate.OkAction     = self.OkAction.ToTemplateAction();
            confirmTemplate.CancelAction = self.CancelAction.ToTemplateAction();

            return(confirmTemplate);
        }
Esempio n. 2
0
        internal static ConfirmTemplate Convert(IConfirmTemplate template)
        {
            if (template.Text == null)
            {
                throw new InvalidOperationException("The text cannot be null.");
            }

            if (!(template is ConfirmTemplate confirmTemplate))
            {
                confirmTemplate = new ConfirmTemplate()
                {
                    Text = template.Text
                };
            }

            if (template.OkAction == null)
            {
                throw new InvalidOperationException("The ok action cannot be null.");
            }

            if (template.CancelAction == null)
            {
                throw new InvalidOperationException("The cancel action cannot be null.");
            }

            confirmTemplate.OkAction     = TemplateAction.Convert(template.OkAction);
            confirmTemplate.CancelAction = TemplateAction.Convert(template.CancelAction);

            return(confirmTemplate);
        }
        private static ITemplate Convert(ITemplate template)
        {
            switch (template)
            {
            case IButtonsTemplate buttonsTemplate:
                return(ButtonsTemplate.Convert(buttonsTemplate));

            case IConfirmTemplate confirmTemplate:
                return(ConfirmTemplate.Convert(confirmTemplate));

            case ICarouselTemplate carouselTemplate:
                return(CarouselTemplate.Convert(carouselTemplate));

            case IImageCarouselTemplate imageCarouselTemplate:
                return(ImageCarouselTemplate.Convert(imageCarouselTemplate));

            default:
                throw new NotSupportedException("Invalid template type.");
            }
        }