コード例 #1
0
        public string Render(AdaptiveCardTemplate template, object model)
        {
            var scriptObject = new ScriptObject();

            if (model != null)
            {
                scriptObject.Import(model, renamer: r => r.Name, filter: null);
            }
            var context = new TemplateContext()
            {
                TemplateLoader            = templateLoader,
                EnableRelaxedMemberAccess = true,
                MemberRenamer             = r => r.Name,
                MemberFilter = null
            };

            context.PushGlobal(scriptObject);

            var builtinFunctions = this.msteamsBuiltinFunctionsFactory();

            context.PushGlobal(builtinFunctions);
            var result = template.Template.Render(context);

            return(result);
        }
コード例 #2
0
        public static AdaptiveCard RenderToAdaptiveCard(this AdaptiveCardTemplateEngine engine, AdaptiveCardTemplate template, object model)
        {
            var result = engine.Render(template, model);

            var card = AdaptiveCard.FromJson(result);

            return(card.Card);
        }