Skip to content

Instantly share code, notes, and snippets.

View DeeJayTC's full-sized avatar
👋
theres nothing to see here...move along!

Tim Cadenbach DeeJayTC

👋
theres nothing to see here...move along!
View GitHub Profile
{
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "20px",
"items": [
// Create card
var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
{
// Use LINQ to turn the choices into submit actions
Actions = choices.Select(choice => new AdaptiveSubmitAction
{
Title = choice,
Data = choice, // This will be a string
}).ToList<AdaptiveAction>(),
};
{
"title": "My list of people:",
"count": 4,
"people": [{
"firstName": "Micky",
"lastName": "Mouse",
"age": 44
},
{
"firstName": "Donald",
{
"{<property>}": "Implicitly binds to `$data.<property>`",
"$data": "The current data object",
"$root": "The root data object. Useful when iterating to escape to parent object",
"$index": "The current index when iterating",
"$host": "Access properties of the host *(not working yet)*"
}
public async Task<string> GetTemplate()
{
var status = new Status() {
Date = DateTime.Now,
User = new User() {
FirstName = NameGenerator.GenerateFirstName(Gender.Male),
LastName = NameGenerator.GenerateLastName()
}
};
var tpl = await System.IO.File.ReadAllTextAsync("./status.json");
@if(Model.Task.TaskDueDate != null)
{
<text>,
{
"title": "Due Date",
"value": "@Model.Task.TaskDueDate.ToShortDateString()"
}
</text>
}
//the underlying CardRenderService
public class CardRenderService
{
private RazorLightEngine Engine;
public CardRenderService()
{
Engine = new RazorLightEngineBuilder().UseMemoryCachingProvider().Build();
}
// Create an adaptive card and send it
var payload = await _cardservice.RenderCard(templateKey, template, data);
var result = await client.PostAsync(url, new StringContent(payload));
@DeeJayTC
DeeJayTC / status.cs
Last active February 21, 2019 15:36
using AdaptiveCards;
// ...
AdaptiveCard card = new AdaptiveCard();
var container = new AdaptiveContainer();
var column = new AdaptiveColumn(){Width=Auto};
column.Items.Add(new AdaptiveImage(
@DeeJayTC
DeeJayTC / adaptivecard.json
Last active February 21, 2019 16:21
Adaptive Cards made easy :)
{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{