Example #1
0
        public void AdaptiveCard()
        {
            JsonTemplate cardTemplate = new JsonTemplate(File.ReadAllText(@"..\..\cardTemplate.json"));
            var          cardData     = JsonConvert.DeserializeObject(File.ReadAllText(@"..\..\cardData.json"));
            var          result       = cardTemplate.Bind(cardData);

            Debug.Print(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
Example #2
0
        private static void TestValueProperty <T>(T value)
        {
            dynamic source = new JObject();

            source.value = value;
            JsonTemplate valueTemplate = new JsonTemplate(@"{ 'prop':'{=value}'}");
            dynamic      result        = valueTemplate.Bind(source);

            Assert.AreEqual((T)result.prop, value);
        }
Example #3
0
        public void ValueComplexStringWithArray()
        {
            dynamic source = new JObject();

            source.items = new JArray(new[] { 1, 2, 3, 4 });
            JsonTemplate valueTemplate = new JsonTemplate(@"{'prop':'result:{items}.'}");
            dynamic      result        = valueTemplate.Bind(source);

            Assert.AreEqual("result:1, 2, 3, 4.", (string)result.prop);
        }
Example #4
0
        public void Join()
        {
            dynamic source = new JObject();

            source.items = new JArray(new[] { 1, 2, 3, 4 });
            JsonTemplate valueTemplate = new JsonTemplate(@"{'template':{'prop':'{items}'}}");
            dynamic      result        = valueTemplate.Bind(source);

            Assert.AreEqual("1, 2, 3, 4", (string)result.prop);
        }
Example #5
0
        public void ValueComplexString()
        {
            dynamic source = new JObject();

            source.value1 = "value1";
            source.value2 = 2;
            JsonTemplate valueTemplate = new JsonTemplate(@"{'prop':'One:{value1} Two:{value2}'}");
            dynamic      result        = valueTemplate.Bind(source);

            Assert.AreEqual("One:value1 Two:2", (string)result.prop);
        }
Example #6
0
        private static void PropertyTestArray <T>(T[] val)
        {
            dynamic source = new JObject();

            source.value = new JArray(val);
            JsonTemplate valueTemplate = new JsonTemplate(@"{ 'prop':'{=value}'}");
            dynamic      result        = valueTemplate.Bind(source);

            Assert.AreEqual(result.prop.Type, JTokenType.Array);
            for (int i = 0; i < val.Length; i++)
            {
                Assert.AreEqual((T)result.prop[i], val[i]);
            }
        }
Example #7
0
        public void Join()
        {
            dynamic source = new JObject();

            source.items = new JArray(new[] { 1, 2, 3, 4 });
            JsonTemplate valueTemplate = new JsonTemplate(@"{'prop':'{items}'}");
            dynamic      result        = valueTemplate.Bind(source);

            Assert.AreEqual("1, 2, 3, 4", (string)result.prop);

            //valueTemplate = new JsonTemplate(@"{'template':{'prop':'{join(items ~sep=_)}'}}");
            //result = valueTemplate.Bind(source);
            //Assert.AreEqual("1_2_3 and 4", (string)result.prop);

            //valueTemplate = new JsonTemplate(@"{'template':{'prop':'{join(items ~sep=_~last= or )}'}}");
            //result = valueTemplate.Bind(source);
            //Assert.AreEqual("1_2_3 or 4", (string)result.prop);
        }
Example #8
0
 public void HotInit()
 {
     var result = complexTemplate.Bind(source);
 }