static (JsonTemplate, string) Evaluate(JsonTemplate template, IReadOnlyDictionary <string, JsonTemplateFunction> functions) { return(template switch { JsonTemplateArray a => EvaluateArray(a, functions), JsonTemplateObject o => EvaluateObject(o, functions), JsonTemplateCall c => EvaluateCall(c, functions), { } other => (other, null), null => throw new ArgumentNullException(nameof(template)) });
public static object Convert(JsonTemplate template) { if (template == null) { throw new ArgumentNullException(nameof(template)); } return(template switch { JsonTemplateNull _ => null, JsonTemplateBoolean b => b.Value, JsonTemplateNumber n => ConvertNumber(n), JsonTemplateString s => s.Value, JsonTemplateArray a => ConvertArray(a), JsonTemplateObject o => ConvertObject(o), JsonTemplateCall c => throw new ArgumentException($"The call `{c.Name}` was not evaluated."), _ => throw new ArgumentOutOfRangeException(nameof(template)), });