예제 #1
0
        public static Task <bool> GetJsExpressionAndEvaluateToBoolAsync(this StringSegment expr, TemplateScopeContext scope, Action ifNone = null)
        {
            if (expr.IsNullOrEmpty())
            {
                ifNone?.Invoke();
                return(TypeConstants.FalseTask);
            }

            var token = expr.GetCachedJsExpression(scope);

            if (token == null)
            {
                ifNone?.Invoke();
                return(TypeConstants.FalseTask);
            }

            return(token.EvaluateToBoolAsync(scope));
        }
예제 #2
0
        public static bool GetJsExpressionAndEvaluateToBool(this StringSegment expr, TemplateScopeContext scope, Action ifNone = null)
        {
            if (expr.IsNullOrEmpty())
            {
                ifNone?.Invoke();
                return(false);
            }

            var token = expr.GetCachedJsExpression(scope);

            if (token == null)
            {
                ifNone?.Invoke();
                return(false);
            }

            var result = token.EvaluateToBool(scope);

            return(result);
        }