Esempio n. 1
0
 internal SM.Bibliography CreateBibliography(SE.Style style, SE.Format format, List <SM.ContentItem> contentItems)
 {
     return(ContentItemFactory.Build(_bibliographyProcessor.CreateBibliography(ContentItemFactory.Build(style),
                                                                               ContentItemFactory.Build(format),
                                                                               contentItems != null ? contentItems.Select(x => ContentItemFactory.Build(x))
                                                                               .ToList()
                                                                                                    : new List <DM.ContentItem>())));
 }
Esempio n. 2
0
        public async Task Run_TestBed()
        {
            var contentRequester   = new ContentRequester();
            var contentItemFactory = new ContentItemFactory();

            var contentItemDto = await contentRequester.GetContentItem("http://localhost:96/api/Contents/Item/12");

            var contentItem = contentItemFactory.Create(contentItemDto);
        }
        public void Create_maps_ContentItem_properties_from_DTO()
        {
            var contentItemFactory = new ContentItemFactory();
            var contentItemDto     = CreateContentItemDto();

            var contentItem = contentItemFactory.Create(contentItemDto);

            contentItem.Id.Should().Be(10);
            contentItem.ContentType.Should().Be("TestContentType");
            contentItem.DisplayType.Should().Be("TestDisplayType");
        }
        private CardContentItem CreateActionsSdkCardFromHeroCard(HeroCard heroCard)
        {
            var card = ContentItemFactory.CreateCard(heroCard.Title, heroCard.Subtitle);

            if (heroCard.Images != null && heroCard.Images.Any())
            {
                card.Card.Image = new Image()
                {
                    Url = heroCard.Images?.FirstOrDefault()?.Url,
                    Alt = heroCard.Images?.FirstOrDefault()?.Alt,
                };
            }

            return(card);
        }
        public void Create_adds_alternates()
        {
            var contentItemFactory = new ContentItemFactory();
            var contentItemDto     = CreateContentItemDto();
            var expectedAlternates = new List <string>
            {
                "ContentItem_10",
                "ContentItem_TestContentType_TestDisplayType",
                "ContentItem_TestContentType",
                "ContentItem_TestDisplayType",
                "ContentItem",
            };

            var contentItem = contentItemFactory.Create(contentItemDto);

            contentItem.Alternates.ShouldBeEquivalentTo(expectedAlternates);
        }
        public void Create_maps_parent_relationships()
        {
            var contentItemFactory  = new ContentItemFactory();
            var contentItemDto      = CreateContentItemDto();
            var expectedContentItem = CreateContentItem();

            var contentItem = contentItemFactory.Create(contentItemDto);

            foreach (var zone in contentItem.Zones)
            {
                zone.ContentItem.Should().Be(contentItem);
                foreach (var element in zone.Elements)
                {
                    element.Zone.Should().Be(zone);
                }
            }
        }
        public void Create_adds_Element_alternates()
        {
            var contentItemFactory = new ContentItemFactory();
            var contentItemDto     = CreateContentItemDto();
            var expectedAlternates = new List <string>
            {
                "TitlePart_10",
                "TitlePart_TestContentType_TestDisplayType_zone1",
                "TitlePart_TestContentType_TestDisplayType",
                "TitlePart_TestContentType",
                "TitlePart_TestDisplayType_zone1",
                "TitlePart_TestDisplayType",
                "TitlePart_zone1",
                "TitlePart",
            };

            var contentItem = contentItemFactory.Create(contentItemDto);

            contentItem.As <TitlePart>().Alternates.ShouldBeEquivalentTo(expectedAlternates);
        }
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            var customer = await Helpers.ServiceHelper.GetCustomerAddress("12345");

            var activityWithCard = MessageFactory.Text("5 minutes away");
            var card             = ContentItemFactory.CreateCard($"Your order {customer.RefNumber} is on its way", "Due to safety for our community, we'll leave the order at your doorstep.",
                                                                 new Link()
            {
                Name = "More details",
                Open = new OpenUrl()
                {
                    Url = "https://www.arafattehsin.com/blog"
                }
            },
                                                                 new Image()
            {
                Url = customer.TrackerURL,
                Alt = "Delivery person on the map"
            }
                                                                 );

            activityWithCard.Attachments.Add(card.ToAttachment());
            await turnContext.SendActivityAsync(activityWithCard, cancellationToken);
        }
Esempio n. 9
0
 internal SM.Citation CreateCitationMagazine(SE.Style style, SE.Format format, SM.Magazine magazine)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationMagazine(ContentItemFactory.Build(style),
                                                                               ContentItemFactory.Build(format),
                                                                               ContentItemFactory.Build(magazine))));
 }
Esempio n. 10
0
 internal SM.Citation CreateCitationBroadcast(SE.Style style, SE.Format format, SM.Broadcast broadcast)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationBroadcast(ContentItemFactory.Build(style),
                                                                                ContentItemFactory.Build(format),
                                                                                ContentItemFactory.Build(broadcast))));
 }
Esempio n. 11
0
 internal SM.Citation CreateCitationInterview(SE.Style style, SE.Format format, SM.Interview interview)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationInterview(ContentItemFactory.Build(style),
                                                                                ContentItemFactory.Build(format),
                                                                                ContentItemFactory.Build(interview))));
 }
Esempio n. 12
0
 internal SM.Citation CreateCitationPresentation(SE.Style style, SE.Format format, SM.Presentation presentation)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationPresentation(ContentItemFactory.Build(style),
                                                                                   ContentItemFactory.Build(format),
                                                                                   ContentItemFactory.Build(presentation))));
 }
Esempio n. 13
0
 internal SM.Citation CreateCitationVideoRecording(SE.Style style, SE.Format format, SM.VideoRecording videoRecording)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationVideoRecording(ContentItemFactory.Build(style),
                                                                                     ContentItemFactory.Build(format),
                                                                                     ContentItemFactory.Build(videoRecording))));
 }
Esempio n. 14
0
 internal SM.Citation CreateCitationGraphic(SE.Style style, SE.Format format, SM.Graphic graphic)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationGraphic(ContentItemFactory.Build(style),
                                                                              ContentItemFactory.Build(format),
                                                                              ContentItemFactory.Build(graphic))));
 }
Esempio n. 15
0
 internal SM.Citation CreateCitationEncyclopedia(SE.Style style, SE.Format format, SM.Encyclopedia encyclopedia)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationEncyclopedia(ContentItemFactory.Build(style),
                                                                                   ContentItemFactory.Build(format),
                                                                                   ContentItemFactory.Build(encyclopedia))));
 }
Esempio n. 16
0
 internal SM.Citation CreateCitationWebpage(SE.Style style, SE.Format format, SM.Webpage webpage)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationWebpage(ContentItemFactory.Build(style),
                                                                              ContentItemFactory.Build(format),
                                                                              ContentItemFactory.Build(webpage))));
 }
Esempio n. 17
0
 internal SM.Citation CreateCitationLegalCase(SE.Style style, SE.Format format, SM.LegalCase legalCase)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationLegalCase(ContentItemFactory.Build(style),
                                                                                ContentItemFactory.Build(format),
                                                                                ContentItemFactory.Build(legalCase))));
 }
Esempio n. 18
0
 internal SM.Citation CreateCitationJournal(SE.Style style, SE.Format format, SM.Journal journal)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationJournal(ContentItemFactory.Build(style),
                                                                              ContentItemFactory.Build(format),
                                                                              ContentItemFactory.Build(journal))));
 }
Esempio n. 19
0
 internal SM.Citation CreateCitationBook(SE.Style style, SE.Format format, SM.Book book)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationBook(ContentItemFactory.Build(style),
                                                                           ContentItemFactory.Build(format),
                                                                           ContentItemFactory.Build(book))));
 }
Esempio n. 20
0
 internal SM.Citation CreateCitationConferencePaper(SE.Style style, SE.Format format, SM.ConferencePaper conferencePaper)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationConferencePaper(ContentItemFactory.Build(style),
                                                                                      ContentItemFactory.Build(format),
                                                                                      ContentItemFactory.Build(conferencePaper))));
 }
Esempio n. 21
0
 internal SM.Citation CreateCitationReport(SE.Style style, SE.Format format, SM.Report report)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationReport(ContentItemFactory.Build(style),
                                                                             ContentItemFactory.Build(format),
                                                                             ContentItemFactory.Build(report))));
 }
Esempio n. 22
0
 internal SM.Citation CreateCitationNewspaper(SE.Style style, SE.Format format, SM.Newspaper newspaper)
 {
     return(ContentItemFactory.Build(_citationProcessor.CreateCitationNewspaper(ContentItemFactory.Build(style),
                                                                                ContentItemFactory.Build(format),
                                                                                ContentItemFactory.Build(newspaper))));
 }
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            switch (turnContext.Activity.Text.ToLower())
            {
            default:
                await turnContext.SendActivityAsync(MessageFactory.Text($"Echo: {turnContext.Activity.Text}. What's next?", inputHint: InputHints.ExpectingInput), cancellationToken);

                break;

            case "finish":
                await turnContext.SendActivityAsync(MessageFactory.Text($"Ok, I won't ask anymore.", inputHint: InputHints.IgnoringInput), cancellationToken);

                break;

            case "card":
                var activityWithCard = MessageFactory.Text($"Ok, I included a simple card.");
                var card             = ContentItemFactory.CreateCard("card title", "card subtitle", new Link()
                {
                    Name = "Microsoft",
                    Open = new OpenUrl()
                    {
                        Url = "https://www.microsoft.com"
                    }
                });
                activityWithCard.Attachments.Add(card.ToAttachment());
                await turnContext.SendActivityAsync(activityWithCard, cancellationToken);

                break;

            case "signin":
                var channelData = (ActionsSdkRequest)turnContext.Activity.ChannelData;
                if (channelData.User.AccountLinkingStatus == "LINKED")
                {
                    await turnContext.SendActivityAsync("You're already signed in!", cancellationToken : cancellationToken);
                }
                else
                {
                    var activityWithSigninCard = MessageFactory.Text($"Ok, I included a signin card.");
                    var signinCard             = new SigninCard();
                    activityWithSigninCard.Attachments.Add(signinCard.ToAttachment());
                    await turnContext.SendActivityAsync(activityWithSigninCard, cancellationToken);
                }

                break;

            case "chips":
                var activityWithChips = MessageFactory.Text($"Ok, I included some suggested actions.");
                activityWithChips.SuggestedActions = new SuggestedActions(actions: new List <CardAction>
                {
                    new CardAction {
                        Title = "Yes", Type = ActionTypes.ImBack, Value = "Y"
                    },
                    new CardAction {
                        Title = "No", Type = ActionTypes.ImBack, Value = "N"
                    },
                    new CardAction {
                        Title = "Click to learn more", Type = ActionTypes.OpenUrl, Value = "http://www.progressive.com"
                    }
                });
                await turnContext.SendActivityAsync(activityWithChips, cancellationToken);

                break;

            case "list":
                var activityWithListAttachment = MessageFactory.Text($"This is a list.");
                var list = new ListContentItem()
                {
                    Title    = "InternalList title",
                    Subtitle = "InternalList subtitle",
                    Items    = new List <ListItem>()
                    {
                        new ListItem()
                        {
                            Key      = "ITEM_1",
                            Synonyms = new List <string>()
                            {
                                "Item 1", "First item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #1",
                                Description = "Description of Item #1",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                        new ListItem()
                        {
                            Key      = "ITEM_2",
                            Synonyms = new List <string>()
                            {
                                "Item 2", "Second item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #2",
                                Description = "Description of Item #2",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                        new ListItem()
                        {
                            Key      = "ITEM_3",
                            Synonyms = new List <string>()
                            {
                                "Item 3", "Third item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #3",
                                Description = "Description of Item #3",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                        new ListItem()
                        {
                            Key      = "ITEM_4",
                            Synonyms = new List <string>()
                            {
                                "Item 4", "Fourth item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #4",
                                Description = "Description of Item #4",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                    }
                };
                activityWithListAttachment.Attachments.Add(list.ToAttachment());
                await turnContext.SendActivityAsync(activityWithListAttachment, cancellationToken);

                break;

            case "collection":
                var activityWithCollectionAttachment = MessageFactory.Text($"Ok, I included a collection.");
                var collection = new CollectionContentItem()
                {
                    Title    = "InternalList title",
                    Subtitle = "InternalList subtitle",
                    Items    = new List <CollectionItem>()
                    {
                        new CollectionItem()
                        {
                            Key      = "ITEM_1",
                            Synonyms = new List <string>()
                            {
                                "Item 1", "First item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #1",
                                Description = "Description of Item #1",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                        new CollectionItem()
                        {
                            Key      = "ITEM_2",
                            Synonyms = new List <string>()
                            {
                                "Item 2", "Second item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #2",
                                Description = "Description of Item #2",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                        new CollectionItem()
                        {
                            Key      = "ITEM_3",
                            Synonyms = new List <string>()
                            {
                                "Item 3", "Third item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #3",
                                Description = "Description of Item #3",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                        new CollectionItem()
                        {
                            Key      = "ITEM_4",
                            Synonyms = new List <string>()
                            {
                                "Item 4", "Fourth item"
                            },
                            Item = new EntryDisplay()
                            {
                                Title       = "Item #4",
                                Description = "Description of Item #4",
                                Image       = new Image()
                                {
                                    Url    = "https://developers.google.com/assistant/assistant_96.png",
                                    Height = 0,
                                    Width  = 0,
                                    Alt    = "Google Assistant logo"
                                }
                            }
                        },
                    }
                };
                activityWithCollectionAttachment.Attachments.Add(collection.ToAttachment());
                await turnContext.SendActivityAsync(activityWithCollectionAttachment, cancellationToken);

                break;

            case "table":
                var activityWithTableCardAttachment = MessageFactory.Text($"Ok, I included a table.");
                var table = ContentItemFactory.CreateTable(
                    new List <TableColumn>()
                {
                    new TableColumn()
                    {
                        Header = "Column 1"
                    },
                    new TableColumn()
                    {
                        Header = "Column 2"
                    }
                },
                    new List <TableRow>()
                {
                    new TableRow()
                    {
                        Cells = new List <TableCell>
                        {
                            new TableCell {
                                Text = "Row 1, Item 1"
                            },
                            new TableCell {
                                Text = "Row 1, Item 2"
                            }
                        }
                    },
                    new TableRow()
                    {
                        Cells = new List <TableCell>
                        {
                            new TableCell {
                                Text = "Row 2, Item 1"
                            },
                            new TableCell {
                                Text = "Row 2, Item 2"
                            }
                        }
                    }
                },
                    "Table Card Title",
                    "Table card subtitle",
                    new Link {
                    Name = "Microsoft", Open = new OpenUrl()
                    {
                        Url = "https://www.microsoft.com"
                    }
                });
                activityWithTableCardAttachment.Attachments.Add(table.ToAttachment());
                await turnContext.SendActivityAsync(activityWithTableCardAttachment, cancellationToken);

                break;
            }
        }