public override Object Evaluate(ILiquidContext context) { if (_fragments == null || _fragments.Count == 0) { return(null); } var val = context[_fragments[0]]; if (_fragments.Count == 1) { return(val); } foreach (var member in _fragments.Skip(1)) { var myObject = val as IDictionary <String, object>; if (myObject == null) { return(null); } val = myObject[member]; } return(val); }
public override Object Evaluate(ILiquidContext context) { switch(Op) { case Operation.Gt: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return left != null && left.CompareTo(right) > 0; } case Operation.Lt: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return left != null && left.CompareTo(right) < 0; } case Operation.LtEq: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return left != null && left.CompareTo(right) <= 0; } case Operation.GtEq: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return left != null && left.CompareTo(right) >= 0; } default: throw new NotImplementedException(); } }
public object Execute(ILiquidContext context) { var result = (bool)_conditionExpr.Evaluate(context); return(result ? _ifBranchStatements.Execute(context) : _elseBranchStatements != null?_elseBranchStatements.Execute(context) : null); }
public object Execute(ILiquidContext context) { if(_outputStr != null) return _outputStr; var val = _expr.Evaluate(context); if (_filters != null) val = _filters.Aggregate(val, (current, filter) => filter.Evaluate(current)); return val.ToString(); }
public object Execute(ILiquidContext context) { throw new NotImplementedException(); /*long initVal = (long)initExpr.Evaluate(); long endVal = (long)endExpr.Evaluate(); for (ielem.Value = initVal; ielem.Value <= endVal; ielem.Value++) { statements.Execute(); }*/ }
public object Execute(ILiquidContext context) { throw new NotImplementedException(); /*long initVal = (long)initExpr.Evaluate(); * long endVal = (long)endExpr.Evaluate(); * for (ielem.Value = initVal; ielem.Value <= endVal; ielem.Value++) * { * statements.Execute(); * }*/ }
public object Execute(ILiquidContext context) { if (_outputStr != null) { return(_outputStr); } var val = _expr.Evaluate(context); if (_filters != null) { val = _filters.Aggregate(val, (current, filter) => filter.Evaluate(current)); } return(val.ToString()); }
public object Execute(ILiquidContext context) { if (_attributes != null && _attributes.Count != 0) { throw new NotImplementedException(); // todo: implement loop attributes } if (!(_value is LookupExpression)) { // TODO: implement FOR... in range throw new NotImplementedException(); /*long initVal = (long)initExpr.Evaluate(); * long endVal = (long)endExpr.Evaluate(); * for (ielem.Value = initVal; ielem.Value <= endVal; ielem.Value++) * { * statements.Execute(); * }*/ } // FOR ... in collection var collection = _value.Evaluate(context) as IEnumerable <object>; if (collection != null) { var result = collection.Select(item => { context[_var] = item; return(_statements.Execute(context)); } ).Where(res => res != null); return(result.Any() ? result.ToList() : null); } throw new NotImplementedException("not collection or range!"); }
public override Object Evaluate(ILiquidContext context) { switch (Op) { case Operation.Gt: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return(left != null && left.CompareTo(right) > 0); } case Operation.Lt: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return(left != null && left.CompareTo(right) < 0); } case Operation.LtEq: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return(left != null && left.CompareTo(right) <= 0); } case Operation.GtEq: { var left = _leftExpression.Evaluate(context) as IComparable; var right = _rightExpression.Evaluate(context) as IComparable; return(left != null && left.CompareTo(right) >= 0); } default: throw new NotImplementedException(); } }
public object Execute(ILiquidContext context) { var l = _statements.Where(st => st != null).Select(st => st.Execute(context)).Where(res => res != null); return(l.Any() ? l.ToList() : null); }
public object Execute(ILiquidContext context) { throw new NotSupportedException("Filter " + _filterName + " can't be executed directly"); }
public override Object Evaluate(ILiquidContext context) { if (_fragments==null || _fragments.Count == 0) return null; var val = context[_fragments[0]]; if(_fragments.Count == 1) return val; foreach(var member in _fragments.Skip(1)) { var myObject = val as IDictionary<String, object>; if(myObject == null) return null; val = myObject[member]; } return val; }
public object Execute(ILiquidContext context) { Evaluate(context); return null; }
public abstract object Evaluate(ILiquidContext context);
public override Object Evaluate(ILiquidContext context) { return _constValue; }
public object Execute(ILiquidContext context) { throw new NotSupportedException("Attribute "+ _attrName + " can't be executed directly"); }
public object Execute(ILiquidContext context) { throw new NotImplementedException(); }
public object Execute(ILiquidContext context) { var result = (bool)_conditionExpr.Evaluate(context); return(!result?_unlessBranchStatements.Execute(context) : _elseBranchStatements.Execute(context)); }
object IStatement.Execute(ILiquidContext context) { throw new NotImplementedException(); }
public object Execute(ILiquidContext context) { Evaluate(context); return(null); }
public override Object Evaluate(ILiquidContext context) { return(_constValue); }
public object Execute(ILiquidContext context) { throw new NotSupportedException("Attribute " + _attrName + " can't be executed directly"); }
public object Execute(ILiquidContext context) { Thread.Sleep((int)timeout); return(null); }
public object Execute(ILiquidContext context) { context[_name] = _exp.Evaluate(context); return(null); }
public object Execute(ILiquidContext context) { throw new NotSupportedException("Filter "+_filterName+" can't be executed directly"); }
public object Execute(ILiquidContext context) { var result = (bool)_conditionExpr.Evaluate(context); return !result ? _unlessBranchStatements.Execute(context) : _elseBranchStatements.Execute(context); }