public bool GetBooleanValue(bool defaultValue = false) { if (bool.TryParse(innerText.ToString(), out var b)) { return(b); } if (innerText == "1") { return(true); } if (innerText == "0") { return(false); } return(defaultValue); }
public IEnumerable <object> Evaluate(SearchContext context, bool reevaluateLiterals = false) { if (expression == null) { return new[] { rawText.ToString() } } ; if (expression.types.HasAny(SearchExpressionType.Literal) && !reevaluateLiterals) { return new[] { value } } ; return(expression.Execute(context).Where(item => item != null).Select(item => item.value)); }
public static string ReplaceMarkersWithRawValues(StringView text, out QueryMarker[] markers) { markers = ParseAllMarkers(text); if (markers == null || markers.Length == 0) { return(text.ToString()); } var modifiedSv = text.GetSubsetStringView(); foreach (var queryMarker in markers) { if (!queryMarker.valid || queryMarker.args == null || queryMarker.args.Length == 0) { continue; } var valueArg = queryMarker.args[0]; modifiedSv.ReplaceWithSubset(queryMarker.text.startIndex, queryMarker.text.endIndex, valueArg.rawText.startIndex, valueArg.rawText.endIndex); } return(modifiedSv.ToString()); }
public static string ReplaceMarkersWithEvaluatedValues(StringView text, SearchContext context) { return(ReplaceMarkersWithEvaluatedValues(text.ToString(), context)); }