Effectuer le rendu d’une carte – HTML .NETRender a card - .NET HTML

Voici comment effectuer le rendu d’une carte à l’aide du Kit de développement logiciel (SDK) HTML .NET.Here's how to render a card using the .NET HTML SDK.

Instancier un convertisseurInstantiate a renderer

L’étape suivante consiste à créer une instance du convertisseur.The next step is to create an instance of the renderer.

using AdaptiveCards;
using AdaptiveCards.Rendering;
using AdaptiveCards.Rendering.Html;
// ... 

// Create a card renderer
AdaptiveCardRenderer renderer = new AdaptiveCardRenderer();

// For fun, check the schema version this renderer supports
AdaptiveSchemaVersion schemaVersion = renderer.SupportedSchemaVersion; // 1.0

Effectuer le rendu d’une carte au format HTMLRender a card to HTML

// Build a simple card
// In the real world this would probably be provided as JSON
AdaptiveCard card = new AdaptiveCard(renderer.SupportedSchemaVersion)
{
    Body = { new AdaptiveTextBlock() { Text = "Hello World" } }
};

try
{
    // Render the card
    RenderedAdaptiveCard renderedCard = renderer.RenderCard(card);

    // Get the output HTML 
    HtmlTag html = renderedCard.Html;

    // (Optional) Check for any renderer warnings
    // This includes things like an unknown element type found in the card
    // Or the card exceeded the maximum number of supported actions, etc
    IList<AdaptiveWarning> warnings = renderedCard.Warnings;
}
catch(AdaptiveException ex)
{
    // Failed rendering
}