/// <summary> /// Adds a local <see cref="TemplateFunction"/> to the context under the supplied name, /// overriding any existing <see cref="TemplateFunction"/> with the same name /// </summary> public void SetLocalFunction(string name, TemplateFunction function) { if (_localFunctions == null) { _localFunctions = new FunctionsDictionary(); } _localFunctions[name] = function; }
/// <summary> /// Retrieves the <see cref="TemplateFunction"/> from the context. Searches through the local functions first then falls back to the global /// </summary> /// <param name="functionName">The name to search for</param> /// <param name="functionEntry">The output result</param> /// <returns>True if the <see cref="TemplateFunction"/> was found, false otherwise</returns> public bool TryGetFunction(string functionName, out TemplateFunction functionEntry) => (_localFunctions != null && _localFunctions.TryGetValue(functionName, out functionEntry)) || _globalFunctions.TryGetValue(functionName, out functionEntry);