protected void RegisterCustomFunction(string name, IScriptCustomFunction func, string category = null) { RegisterVariable(name, func, category); }
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); } } }
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); } }