public override Func <ResultRow, bool> GetResultFilter(TemplateParameters p) { var tvp = (TokenValueProvider)ValueProvider !; if (Operation == null) { var column = p.Columns[tvp.ParsedToken.QueryToken !];
public override IEnumerable <object> GetFilteredRows(TemplateParameters p, FilterOperation?operation, string stringValue) { if (operation == null) { var column = p.Columns[ParsedToken.QueryToken]; var filtered = p.Rows.Where(r => ToBool(r[column])).ToList(); return(filtered); } else { var type = this.Type; object val = FilterValueConverter.Parse(stringValue, type, operation.Value.IsList()); Expression value = Expression.Constant(val, type); ResultColumn col = p.Columns[ParsedToken.QueryToken]; var expression = Signum.Utilities.ExpressionTrees.Linq.Expr((ResultRow rr) => rr[col]); Expression newBody = QueryUtils.GetCompareExpression(operation.Value, Expression.Convert(expression.Body, type), value, inMemory: true); var lambda = Expression.Lambda <Func <ResultRow, bool> >(newBody, expression.Parameters).Compile(); var filtered = p.Rows.Where(lambda).ToList(); return(filtered); } }
public override object GetValue(TemplateParameters p) { var entity = (Lite <Entity>)p.Rows.DistinctSingle(p.Columns[EntityToken]); var fallback = (string)p.Rows.DistinctSingle(p.Columns[ParsedToken.QueryToken]); return(entity == null ? null : TranslatedInstanceLogic.TranslatedField(entity, Route, fallback)); }
public override Func <ResultRow, bool> GetResultFilter(TemplateParameters p) { var left = LeftNode.GetResultFilter(p); var right = RightNode.GetResultFilter(p); return(rr => left(rr) || right(rr)); }
public virtual IEnumerable <object> GetFilteredRows(TemplateParameters p) { var filter = this.GetResultFilter(p); var filtered = p.Rows.Where(filter).ToList(); return(filtered); }
public override object GetValue(TemplateParameters p) { if (p.Rows.IsEmpty()) { return(null); } return(p.Rows.DistinctSingle(p.Columns[ParsedToken.QueryToken])); }
public override IEnumerable <object> GetFilteredRows(TemplateParameters p) { if (this.ValueProvider is TokenValueProvider) { return(base.GetFilteredRows(p)); } else { var collection = (IEnumerable)this.ValueProvider !.GetValue(p) !; return(collection.Cast <object>()); } }
public override object GetValue(TemplateParameters p) { object value = p.GetModel(); foreach (var m in Members) { value = Getter(m, value); if (value == null) { break; } } return(value); }
public override void Foreach(TemplateParameters p, Action forEachElement) { var groups = p.Rows.GroupBy(r => r[p.Columns[ParsedToken.QueryToken]], TemplateUtils.SemiStructuralEqualityComparer.Comparer).ToList(); if (groups.Count == 1 && groups[0].Key == null) { return; } foreach (var group in groups) { using (p.OverrideRows(group)) forEachElement(); } }
public virtual void Foreach(TemplateParameters p, Action forEachElement) { var collection = (IEnumerable)this.GetValue(p); foreach (var item in collection) { using (p.Scope()) { if (this.Variable != null) { p.RuntimeVariables.Add(this.Variable, item); } forEachElement(); } } }
public override object GetValue(TemplateParameters p) { if (!p.RuntimeVariables.TryGetValue(Parent.Variable, out object value)) { throw new InvalidOperationException("Variable {0} not found".FormatWith(Parent.Variable)); } foreach (var m in Members) { value = Getter(m, value); if (value == null) { break; } } return(value); }
public bool GetCondition(TemplateParameters p, FilterOperation?operation, string valueString) { var obj = this.GetValue(p); if (operation == null) { return(ToBool(obj)); } else { var type = this.Type; Expression token = Expression.Constant(obj, type); Expression value = Expression.Constant(FilterValueConverter.Parse(valueString, type, operation.Value.IsList()), type); Expression newBody = QueryUtils.GetCompareExpression(operation.Value, token, value, inMemory: true); var lambda = Expression.Lambda <Func <bool> >(newBody).Compile(); return(lambda()); } }
public override bool Evaluate(TemplateParameters p) { var obj = ValueProvider !.GetValue(p); if (Operation == null) { return(ToBool(obj)); } else { var type = this.ValueProvider.Type !; Expression token = Expression.Constant(obj, type); Expression value = Expression.Constant(FilterValueConverter.Parse(Value, type, Operation.Value.IsList()), type); Expression newBody = QueryUtils.GetCompareExpression(Operation.Value, token, value, inMemory: true); var lambda = Expression.Lambda <Func <bool> >(newBody).Compile(); return(lambda()); } }
public override object GetValue(TemplateParameters p) { object value = GlobalVariables[globalKey].GetValue(p); if (value == null) { return(null); } if (Members != null) { foreach (var m in Members) { value = ModelValueProvider.Getter(m, value); if (value == null) { break; } } } return(value); }
public override object GetValue(TemplateParameters p) { return(dateTimeExpression == null ? DateTime.Now : FilterValueConverter.Parse(this.dateTimeExpression, typeof(DateTime?), false)); }
public override void Foreach(TemplateParameters parameters, Action forEachElement) { throw new NotImplementedException("{0} can not be used to foreach".FormatWith(typeof(TranslateInstanceValueProvider).Name)); }
public abstract object GetValue(TemplateParameters p);
public abstract bool Evaluate(TemplateParameters p);
public virtual IEnumerable <object> GetFilteredRows(TemplateParameters p, FilterOperation?operation, string stringValue) { var collection = (IEnumerable)this.GetValue(p); return(collection.Cast <object>()); }
public override bool Evaluate(TemplateParameters p) { return(this.LeftNode.Evaluate(p) && this.RightNode.Evaluate(p)); }
public abstract Func <ResultRow, bool> GetResultFilter(TemplateParameters p);