public void Create_ListTemplate2()
        {
            var actual = new ListTemplate2
            {
                Token           = "A2079",
                Title           = "My Favourite Pizzas",
                BackButton      = BackButtonVisibility.Visible,
                BackgroundImage = new TemplateImage
                {
                    ContentDescription = "Textured grey background",
                    Sources            = new List <ImageSource>
                    {
                        new ImageSource {
                            Url = "https://www.example.com/background-image1.png"
                        }
                    }
                },
                Items = new List <ListItem>
                {
                    new ListItem
                    {
                        Token   = "item_1",
                        Content = new TemplateContent
                        {
                            Primary = new TemplateText
                            {
                                Text = "<font size='7'>Supreme</font> <br/> Large Pan Pizza $17.00",
                                Type = TextType.Rich
                            },
                            Secondary = new TemplateText
                            {
                                Text = "Secondary Text",
                                Type = TextType.Plain
                            },
                            Tertiary = new TemplateText
                            {
                                Text = string.Empty,
                                Type = TextType.Plain
                            }
                        },
                        Image = new TemplateImage
                        {
                            Sources = new List <ImageSource> {
                                new ImageSource
                                {
                                    Url = "http://www.example.com/images/thumb/SupremePizza1.jpg"
                                }
                            },
                            ContentDescription = "Supreme Large Pan Pizza"
                        }
                    }
                }
            };

            Assert.True(CompareJson(actual, "TemplateListTemplate2.json"));
        }
예제 #2
0
        /// <summary>
        /// Creates the metosat response.
        /// </summary>
        /// <param name="infrared">if set to <c>true</c> [infrared].</param>
        /// <returns></returns>
        private static SkillResponse CreateResponse(bool infrared)
        {
            string        text     = infrared ? "Ecco le ultime immagini all' infraross dal satellite meteosàt" : "Ecco le ultime immagini dal satellite meteosàt";
            SkillResponse response = ResponseBuilder.Tell(text);
            DisplayRenderTemplateDirective display = new DisplayRenderTemplateDirective();

            var bodyTemplate = new ListTemplate2
            {
                Title      = "Immagini meteosat",
                BackButton = "HIDDEN"
            };

            foreach (KeyValuePair <string, string> info in infos)
            {
                var image = new TemplateImage()
                {
                    ContentDescription = $"Vista {info.Key}"
                };

                string url = infrared ? $"https://api.sat24.com/mostrecent/{info.Value}/infraPolair" : $"https://api.sat24.com/mostrecent/{info.Value}/visual5hdcomplete";

                image.Sources.Add(new ImageSource()
                {
                    Url    = url,
                    Height = 615,
                    Width  = 845,
                });

                ListItem item = new ListItem
                {
                    Image   = image,
                    Content = new TemplateContent
                    {
                        Primary = new TemplateText()
                        {
                            Text = $"{info.Key}",
                            Type = "PlainText"
                        }
                    }
                };

                bodyTemplate.Items.Add(item);
            }

            display.Template = bodyTemplate;
            response.Response.Directives.Add(display);
            response.Response.ShouldEndSession = false;
            return(response);
        }