コード例 #1
0
ファイル: TemplateVisitor.cs プロジェクト: rexzh/RexToy
        internal TemplateVisitor(ITemplateContext ctx, ExpressionLanguageEngineConfig cfg)
        {
            _ctx    = ctx;
            _engine = ExpressionLanguageEngine.CreateEngine(cfg, _ctx);

            _str = new StringBuilder();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 public void SetUp()
 {
     engine = ExpressionLanguageEngine.CreateEngine(new Eval());
 }