public TagModel(IModel model, ISimpleSessionState session, IModel request, IResponse response) { _model = model; _page = new Reflection(new Hashtable()); _request = request; _session = session != null ? new Reflection(session) : null; _internal = new Reflection(this); _response = response; }
public override object Evaluate(IModel model) { if(_bracketIndexers==null) return model[_name]; var t = model[_name]; foreach (var expression in _bracketIndexers) { t=new Reflection(t).GetDirectProperty(expression.Evaluate(model)?.ToString()); } return t; }
public void EagerShouldAllowForEmptyString() { var reflection = new Reflection(new SampleModel()); var e = new ExpressionLib().Parse("Name == ''"); Assert.That(e.Evaluate(reflection), Is.False); }
public void EagerShouldFailOnUnparsedEnd() { var reflection = new Reflection(new SampleModel()); try { var e = new ExpressionLib().Parse("'true' or false'"); Assert.Fail("Parse error expected"); } catch (ParseException EPe) { Assert.That(EPe.MessageWithOutContext, Is.EqualTo(ParseException.ExpectedToken().Message)); } }
public void TestAdditionalNameForOr() { var reflection = new Reflection(new SampleModel()); Assert.That(new ExpressionLib().ParseAndEvaluate("'true' or 'false'", reflection), Is.EqualTo(new ExpressionLib().ParseAndEvaluate("'true'||'false'", reflection))); }
public void TestAdditionalNameForPower() { var reflection = new Reflection(new SampleModel()); Assert.That(new ExpressionLib().ParseAndEvaluate("'6' pow '2'", reflection), Is.EqualTo(new ExpressionLib().ParseAndEvaluate("'6'^'2'", reflection))); }
public void TestAdditionalNameForGreaterThanOrEqual() { var reflection = new Reflection(new SampleModel()); Assert.That(new ExpressionLib().ParseAndEvaluate("'6' ge '2'", reflection), Is.EqualTo(new ExpressionLib().ParseAndEvaluate("'6'>='2'", reflection))); }
public void Should_Handle_Function_With_Zero_Arguments() { var reflection = new Reflection(new SampleModel()); var e = new ExpressionLib().Parse("fn:now()"); Assert.That(e.ReturnType, Is.Not.Null); Assert.That(e.ReturnType, Is.EqualTo(typeof(DateTime))); }
public void ShouldHaveReturnTypeOfExpression_int() { var reflection = new Reflection(new SampleModel()); var e = new ExpressionLib().Parse("'6' + '7'"); Assert.That(e.ReturnType, Is.Not.Null); Assert.That(e.ReturnType, Is.EqualTo(typeof(decimal))); }
public void ShouldHaveReturnTypeOfConstants_bool() { var reflection = new Reflection(new SampleModel()); var e = new ExpressionLib().Parse("'false'"); Assert.That(e.ReturnType, Is.Not.Null); Assert.That(e.ReturnType, Is.EqualTo(typeof(bool))); }
public ReflectionAttributeSetter(object tag) { _tag = new Reflection(tag); }