public static object?Parse(IHandlebars context, object?argument, bool convertObjectArrayToStringList = false) { switch (argument) { case string valueAsString: return(StringValueParser.Parse(context, valueAsString)); case UndefinedBindingResult valueAsUndefinedBindingResult: if (TryParseUndefinedBindingResult(valueAsUndefinedBindingResult, out List <object?>?parsedAsObjectList)) { if (convertObjectArrayToStringList) { return(parsedAsObjectList.Cast <string?>().ToList()); } return(parsedAsObjectList); } return(argument); case IDictionary <string, object?> hash: return(hash); default: return(argument); } }
public static object ParseAsIntLongOrDouble(IHandlebars context, object value) { var parsedValue = StringValueParser.Parse(context, value is string stringValue ? stringValue : value.ToString()); if (SupportedTypes.Contains(parsedValue.GetType())) { return(parsedValue); } throw new NotSupportedException($"The value '{value}' cannot not be converted to an int, long or double."); }