Example #1
0
        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);
        }
Example #2
0
 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();
     }
 }
Example #3
0
        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();
     }*/
 }
Example #6
0
        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());
        }
Example #8
0
        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!");
        }
Example #9
0
        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();
            }
        }
Example #10
0
        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");
 }
Example #12
0
        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;
        }
Example #13
0
 public object Execute(ILiquidContext context)
 {
     Evaluate(context);
     return null;
 }
Example #14
0
 public abstract object Evaluate(ILiquidContext context);
Example #15
0
 public override Object Evaluate(ILiquidContext context)
 {
     return _constValue;
 }
Example #16
0
 public object Execute(ILiquidContext context)
 {
     throw new NotSupportedException("Attribute "+ _attrName + " can't be executed directly");
 }
Example #17
0
 public object Execute(ILiquidContext context)
 {
     throw new NotImplementedException();
 }
Example #18
0
        public object Execute(ILiquidContext context)
        {
            var result = (bool)_conditionExpr.Evaluate(context);

            return(!result?_unlessBranchStatements.Execute(context) : _elseBranchStatements.Execute(context));
        }
Example #19
0
 object IStatement.Execute(ILiquidContext context)
 {
     throw new NotImplementedException();
 }
Example #20
0
 object IStatement.Execute(ILiquidContext context)
 {
     throw new NotImplementedException();
 }
Example #21
0
 public abstract object Evaluate(ILiquidContext context);
Example #22
0
 public object Execute(ILiquidContext context)
 {
     Evaluate(context);
     return(null);
 }
Example #23
0
 public override Object Evaluate(ILiquidContext context)
 {
     return(_constValue);
 }
Example #24
0
 public object Execute(ILiquidContext context)
 {
     throw new NotSupportedException("Attribute " + _attrName + " can't be executed directly");
 }
 public object Execute(ILiquidContext context)
 {
     throw new NotImplementedException();
 }
Example #26
0
 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);
 }