using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using AdaptiveCards.Templating;
public static void Test()
var layout = GetCardJson();
var content = GetCardContentJson();
Console.WriteLine(JToken.Parse(layout));
AdaptiveCardTemplate template = new AdaptiveCardTemplate(layout);
Console.WriteLine("read template: {0}. cardJson:", template);
string cardJson = template.Expand(content);
Console.WriteLine(cardJson);
AdaptiveCardParseResult card = AdaptiveCard.FromJson(cardJson);
Console.WriteLine("{0} card created successfully with card.Card.ToJson():", card);
Console.WriteLine(card.Card.ToJson());
static string GetCardJson()
""type"": ""AdaptiveCard"",
""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
""text"": ""${formatDateTime($root.AdditionalData['DUE-DATE'], 'd.M.yyyy')}"",
static string GetCardContentJson()
""Name"" : ""Matt Hidinger"",
""date"" : ""2021-09-10T16:29:59Z"",
""DUE-DATE"": ""2021-09-10T16:29:59Z""
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("{0} version: {1}", typeof(AdaptiveCard).Assembly.GetName().Name, typeof(AdaptiveCard).Assembly.FullName);
Console.WriteLine("{0} version: {1}", typeof(AdaptiveCardTemplate).Assembly.GetName().Name, typeof(AdaptiveCardTemplate).Assembly.FullName);
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Assembly.GetName().Name, typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];