Exemple #1
0
 protected void RegisterCustomFunction(string name, IScriptCustomFunction func, string category = null)
 {
     RegisterVariable(name, func, category);
 }
Exemple #2
0
        static IEnumerable FilterInternal(TemplateContext context, ScriptNode callerContext, SourceSpan span, IEnumerable list, IScriptCustomFunction function, Type destType)
        {
            var arg = new ScriptArray(1);

            foreach (var item in list)
            {
                var itemToTransform = context.ToObject(span, item, destType);
                arg[0] = itemToTransform;
                var itemTransformed = ScriptFunctionCall.Call(context, callerContext, function, arg);
                if (context.ToBool(span, itemTransformed))
                {
                    yield return(itemToTransform);
                }
            }
        }
Exemple #3
0
        private static IEnumerable EachInternal(TemplateContext context, SourceSpan span, IEnumerable list, IScriptCustomFunction function, Type destType)
        {
            var arg = new ScriptArray(1);

            foreach (var item in list)
            {
                var itemToTransform = context.ToObject(span, item, destType);
                arg[0] = itemToTransform;
                var itemTransformed = ScriptFunctionCall.Call(context, context.CurrentNode, function, arg);
                yield return(itemTransformed);
            }
        }