internal TemplateVisitor(ITemplateContext ctx, ExpressionLanguageEngineConfig cfg) { _ctx = ctx; _engine = ExpressionLanguageEngine.CreateEngine(cfg, _ctx); _str = new StringBuilder(); }
public void Test() { ExpressionLanguageEngine engine = ExpressionLanguageEngine.CreateEngine(); engine.Assign("m", 10); engine.Assign("v", 5); float E = engine.Eval <float>("m*v*v/2"); Assert.AreEqual(125, E); }
protected override void DoCheck(IValidateResult result, object instance, object propertyValue) { //Extend:use cache to improve performance. ExpressionLanguageEngineConfig cfg = new ExpressionLanguageEngineConfig(EvalExceptionHandlingPolicy.IgnorePolicy); ExpressionLanguageEngine engine = ExpressionLanguageEngine.CreateEngine(cfg); engine.Assign(INSTANCE, instance); engine.Assign(VALUE, propertyValue); object b = engine.Eval(_expr); if (!engine.EvalToBool(b)) { string msg = string.Format(MSG, _pInfo.Name, instance.GetType().Name, propertyValue, _expr); this.LogValidateResult(result, msg); } }
public void SetUp() { engine = ExpressionLanguageEngine.CreateEngine(new Eval()); }