Esempio n. 1
0
        public void TestScientificWithFunctionExpression()
        {
            var context = new TemplateContext();

            context.BuiltinObject.SetValue("clear", DelegateCustomFunction.CreateFunc <ScriptExpression, string>(FunctionClear), false);
            context.BuiltinObject.SetValue("history", DelegateCustomFunction.Create <object>(FunctionHistory), false);

            var template = Template.Parse("clear history", lexerOptions: new LexerOptions()
            {
                Lang = ScriptLang.Scientific,
                Mode = ScriptMode.ScriptOnly
            });

            var test = template.Render(context);

            Assert.AreEqual("history", test);

            template = Template.Parse("clear history * 5", lexerOptions: new LexerOptions()
            {
                Lang = ScriptLang.Scientific,
                Mode = ScriptMode.ScriptOnly
            });
            test = template.Render(context);
            Assert.AreEqual("history*5", test);
        }
Esempio n. 2
0
 protected void RegisterAction <T1, T2, T3, T4>(string name, Action <T1, T2, T3, T4> action, string category = null)
 {
     RegisterCustomFunction(name, DelegateCustomFunction.Create(action), category);
 }
Esempio n. 3
0
 protected void RegisterAction(string name, Action action, string category = null)
 {
     RegisterFunction(name, DelegateCustomFunction.Create(action), category);
 }