20 lines
510 B
C#
20 lines
510 B
C#
namespace Bts.BooleanExpressions;
|
|
|
|
using bts;
|
|
|
|
class BooleanExpression : IBooleanExpression {
|
|
readonly Func<IDictionary<string, object?>, bool> evaluate;
|
|
|
|
public BooleanExpression(Func<IDictionary<string, object?>, bool> evaluate) =>
|
|
this.evaluate = evaluate;
|
|
|
|
public bool Evaluate(IDictionary<string, object?> env) {
|
|
try {
|
|
return evaluate(env);
|
|
} catch (Exception ex) {
|
|
Log.assert(false, $"BooleanExpression.Evaluate failed: {ex}");
|
|
throw;
|
|
}
|
|
}
|
|
}
|