From 0f04dabe2e9503cada19255bc49b2797dad98938 Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Thu, 14 Feb 2019 18:41:21 +0100 Subject: [PATCH] Expression.IsTrue(...) --- Expression.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Expression.cs b/Expression.cs index b35a72d..6e3f22f 100644 --- a/Expression.cs +++ b/Expression.cs @@ -31,7 +31,24 @@ namespace ln.templates return TopEval.Evaluate(context); } - + public bool IsTrue(Context context) + { + try + { + object v = Evaluate(context); + if ((v is bool) && ((bool)v)) + return true; + if ((v is string) && (!String.Empty.Equals(v))) + return true; + if ((v is int) && ((int)v != 0)) + return true; + return false; + } + catch (Exception e) + { + return false; + } + } private void Compile()