Пример #1
0
        // Helper Method to modify the Adaptive Card template.
        public static AdaptiveCard GetAdaptiveCard(Prospect userProfile)
        {
            // Found flight number, just return the flight details now.
            string json = System.IO.File.ReadAllText(@"Data\\Assets\\Card.json");
            var    card = AdaptiveCards.AdaptiveCard.FromJson(json).Card;
            var    body = card.Body;

            // Fact
            AdaptiveFactSet adaptiveFactSet = (AdaptiveCards.AdaptiveFactSet)body[2];

            // Name
            AdaptiveFact name = (AdaptiveFact)adaptiveFactSet.Facts[0];

            name.Value = userProfile.Name;

            // Phone Number
            AdaptiveFact phoneNumber = (AdaptiveFact)adaptiveFactSet.Facts[1];

            phoneNumber.Value = userProfile.PhoneNumber;

            // Email Address
            AdaptiveFact emailAddr = (AdaptiveFact)adaptiveFactSet.Facts[2];

            emailAddr.Value = userProfile.Email;

            return(card);
        }
Пример #2
0
        // Helper Method to modify the Adaptive Card template.
        public static AdaptiveCard GetAdaptiveCard(Attendee userProfile)
        {
            string json = System.IO.File.ReadAllText(@"Assets\\Card.json");
            var    card = AdaptiveCards.AdaptiveCard.FromJson(json).Card;
            var    body = card.Body;

            // Fact
            AdaptiveFactSet adaptiveFactSet = (AdaptiveCards.AdaptiveFactSet)body[2];

            // Name
            AdaptiveFact name = (AdaptiveFact)adaptiveFactSet.Facts[0];

            name.Value = userProfile.Name;

            // Phone Number
            AdaptiveFact phoneNumber = (AdaptiveFact)adaptiveFactSet.Facts[1];

            phoneNumber.Value = userProfile.PhoneNumber;

            // Email Address
            AdaptiveFact emailAddr = (AdaptiveFact)adaptiveFactSet.Facts[2];

            emailAddr.Value = userProfile.Email;

            return(card);
        }
        private List <AdaptiveElement> TransformGroupAsFactSetToElements(List <AdaptiveBlock> group, AdaptiveBlockTransformContext context)
        {
            AdaptiveFactSet factSet = new AdaptiveFactSet();

            foreach (var block in group)
            {
                AdaptiveFact fact = new AdaptiveFact()
                {
                    Title = block.View?.Content?.Title,
                    Value = block.View?.Content?.Subtitle
                };

                factSet.Facts.Add(fact);
            }

            return(new List <AdaptiveElement>()
            {
                factSet
            });
        }
Пример #4
0
        public void FactSet()
        {
            AdaptiveFact fact1 = new AdaptiveFact
            {
                Title    = "Title1",
                Value    = "Value1",
                Language = "en"
            };

            Assert.AreEqual("Title1", fact1.Title);
            Assert.AreEqual("Value1", fact1.Value);
            Assert.AreEqual("en", fact1.Language);

            AdaptiveFact fact2 = new AdaptiveFact
            {
                Title = "Title2",
                Value = "Value2",
            };

            AdaptiveFactSet factSet = new AdaptiveFactSet
            {
                Height    = HeightType.Stretch,
                Id        = "FactSetId",
                IsVisible = false,
                Separator = true,
                Spacing   = Spacing.Medium,
            };

            ValidateBaseElementProperties(factSet, "FactSetId", false, true, Spacing.Medium, HeightType.Stretch);

            factSet.Facts.Add(fact1);
            factSet.Facts.Add(fact2);

            Assert.AreEqual("Value1", factSet.Facts[0].Value);
            Assert.AreEqual("Value2", factSet.Facts[1].Value);

            var jsonString = factSet.ToJson().ToString();

            Assert.AreEqual("{\"facts\":[{\"title\":\"Title1\",\"value\":\"Value1\"},{\"title\":\"Title2\",\"value\":\"Value2\"}],\"height\":\"Stretch\",\"id\":\"FactSetId\",\"isVisible\":false,\"separator\":true,\"spacing\":\"medium\",\"type\":\"FactSet\"}", jsonString);
        }
Пример #5
0
 public virtual void Visit(AdaptiveFact fact)
 {
 }