在bot框架中设置自适应卡的主机配置



我想知道如何将hostconfig设置为我的样式自适应卡。我是bot框架的新手,想知道如何在c#中实现自适应卡的主机配置,甚至已经检查过了[https://learn.microsoft.com/en-us/adaptive-cards/sdk/rendering-cards/javascript/host-config]。这是我在card.json下面的自适应卡,并指导我一步一步地为下面的卡创建主机配置。

{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"actions": [
{
"type": "Action.Submit",
"title": "Sign-up",
"data": "${signin}",
"id": "7"
},
{
"type": "Action.Submit",
"title": "Password Reset",
"data": "${preset}",
"id": "8"
}
],
"body": [
{
"type": "TextBlock",
"wrap": true,
"text": "Menu",
"style": "heading",
"fontType": "Default",
"color": "Good",
"weight": "Bolder",
"id": "1"
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ShowCard",
"title": "Sign-in",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Username",
"label": "Your name (Last, First)",
// "validation": "^[A-Z][a-z]+, [A-Z][a-z]+$",
"data": "${username}",
"wrap": true,
"id": "3"
},
{
"type": "TextBlock",
"text": "Password",
"wrap": true,
"id": "5"
},
{
"type": "Input.Text",
"placeholder": "***********",
"style": "padding=2px",
"id": "6"
}
]
},
"id": "2"
}
]
}
]

}

您可以用这种方式尝试。

// Construct programmatically
renderer.HostConfig = new AdaptiveHostConfig() 
{
FontFamily = "Comic Sans",
FontSizes = {
Small = 15,
Default = 20,
Medium = 25,
Large = 30,
ExtraLarge= 40
}
};
// Or parse from JSON
renderer.HostConfig  = AdaptiveHostConfig.FromJson(@"{
""fontFamily"": ""Comic Sans"",
""fontSizes"": {
""small"": 25,
""default"": 26,
""medium"": 27,
""large"": 28,
""extraLarge"": 29
}
}");

请参阅此链接。https://learn.microsoft.com/en-us/adaptive-cards/sdk/rendering-cards/net-html/host-config