用于机器人框架版本 4 C# 的自适应卡片 nuget 包

Adaptive Cards nuget package to be used for bot frameworks version 4 C#

我不确定从第 3 版迁移过来的第 4 版机器人应用程序中的自适应卡要包含的 nuget 包。可用的选项是 AdaptiveCards nuget 包和 Microsoft.AdaptiveCards(均由 Microsoft ).在版本 3 中,我们使用了 adaptiveCards(来自 AdaptiveCards)。

我们在第 3 版应用程序中使用了自适应卡的以下 nuget 包(由 AdaptiveCards 提供)Adaptive cards,请帮助我将 nuget 包用于同一应用程序的第 4 版,以便更改在现有代码中完成的工作可能最少且节省时间。

当我在 v4 应用程序和自适应卡方法中添加建议的包时,出现错误 'AdaptiveCards is obselete. Please use the overload that accepts the version parameter and specify the version your card requires.'

自适应卡片中的一种方法Class:

     //Create an adaptive card to show the SharePoint search result      


       public static Attachment SPSearchAdapativecard(string title, string summery, string actionUrl)
    {
        summery = summery.Replace("<c0>", "**");
        summery = summery.Replace("</c0>", "**");
        summery = summery.Replace("<ddd/>", "...");

        AdaptiveCard card = new AdaptiveCard()
        {
            Body = new List<AdaptiveElement>()
            {

                    new AdaptiveTextBlock()
                    {
                       Text = title,
                       Weight = AdaptiveTextWeight.Bolder,
                       Size = AdaptiveTextSize.Medium,
                       Wrap=false,
                       Separator = false,
                       Color= AdaptiveTextColor.Accent
                    },
                     new AdaptiveTextBlock()
                    {
                       Text = summery,
                       Wrap=true,
                       Size = AdaptiveTextSize.Small
                    },
            },
            Actions = new List<AdaptiveAction>()
            {
                new AdaptiveOpenUrlAction()
                {
                    Id = "moreInfoBtn",
                    Title= "More Info",
                    Url= new Uri(actionUrl)
                }
            }
        };
        // Create the attachment with adapative card.  
        Attachment attachment = new Attachment()
        {
            ContentType = AdaptiveCard.ContentType,
            Content = card
        };
        return attachment;
    }

如果你查看 Nuget.org (here) 上的 Microsoft.AdaptiveCards 包,你会发现它是旧的 Deprecated。最后更新时间是 17/09/2017

然后 AdaptiveCards Nuget:版本是几天前的,初始版本是 24/10/2017:这个包是前面提到的包的继承者。

此外,如果您查看 GitHub 上的 Bot Builder 样本,其中有一个用于自适应卡片 here

查看引用的包: