public Aggregator() { Node = new AggregateNode(); Routers = new List <IRouter>(); Collectors = new List <ICollector>(); Finalizers = new List <IFinalizer>(); }
private void ProcessRetriever(object obj, IScope scope, IRouter retriever, AggregateNode current) { if (!retriever.Filter(obj, current, scope)) { return; } var subnode = string.IsNullOrWhiteSpace(retriever.Key) ? current : current.GetNode(retriever.Key); subnode.IsBucket = true; subnode.RouteKey = new RouteKey(retriever.Key); AggregateNode keynode = subnode; SetValues(obj, scope, subnode); var key = retriever.GetKey(obj, scope); if (null != key) { keynode = subnode.GetNode(key.Key); keynode.RouteKey = key; SetValues(obj, scope, keynode); } if (retriever.HasChildren) { foreach (var r in retriever.Children) { ProcessRetriever(obj, scope, r, keynode); } } }
public virtual void Execute(AggregateNode node) { if (null != ExecuteFunction) { ExecuteFunction(node); } }
public virtual bool Filter(object o, AggregateNode current, IScope scope) { if (null != FilterFunc) { return(FilterFunc(o, current, scope)); } return(true); }
protected virtual object InternalGetValue(object src, object currentValue, AggregateNode trg, IScope scope) { if (null != ValueFunction) { { return(ValueFunction(src, currentValue, trg, scope)); } } return(null); }
public override object GetValue(object src, object currentValue, AggregateNode trg, IScope scope) { var result = InternalGetValue(src, currentValue, trg, scope); if (null != result) { var dec = result.ToDecimal(); var current = currentValue.ToDecimal(); return(current + dec); } return(currentValue); }
public override object GetValue(object src, object currentValue, AggregateNode trg, IScope scope) { var result = InternalGetValue(src, currentValue, trg, scope); if (!Equals(0,result)) { var i = result.ToInt(); if (0 == i) { i = 1; } return currentValue.ToInt() + i; } return currentValue.ToInt(); }
public override object GetValue(object src, object currentValue, AggregateNode trg, IScope scope) { var result = InternalGetValue(src, currentValue, trg, scope); if (!Equals(0, result)) { var i = result.ToInt(); if (0 == i) { i = 1; } return(currentValue.ToInt() + i); } return(currentValue.ToInt()); }
private void SetValues(object obj, IScope scope, AggregateNode current) { foreach (var collector in Collectors) { if (!collector.Filter(obj, current, scope)) { continue; } var currentValue = current.GetValue(collector.Key); var newValue = collector.GetValue(obj, currentValue, current, scope); if (currentValue != newValue && null != newValue) { current.SetValue(collector.Key, newValue); } } }
public override object GetValue(object src, object currentValue, AggregateNode trg, IScope scope) { var result = InternalGetValue(src, currentValue, trg, scope); if (null == result) { return(currentValue); } var key = trg.Id + "_" + this.Id; var val = result.ToStr(); var vals = scope.Ensure(key, new List <string>()); if (vals.Contains(val)) { return(currentValue); } vals.Add(val); return(currentValue.ToInt() + 1); }
public AggregateNode GetNode(string name, params string[] path) { if (name.Contains("/") || name.Contains(".")) { var p = name.SmartSplit(false, true, '/', '.'); return(GetNode(p[0], p.Skip(1).ToArray())); } if (path != null && 0 != path.Length) { var current = GetNode(name); foreach (var s in path) { current = current.GetNode(s); } return(current); } if (!Children.ContainsKey(name)) { return(Children[name] = new AggregateNode { Parent = this }); } return(Children[name]); }
public virtual bool Filter(object src, AggregateNode trg, IScope scope) { return(true); }
public virtual object GetValue(object src, object currentValue, AggregateNode trg, IScope scope) { var result = InternalGetValue(src, currentValue, trg, scope); return(result ?? currentValue); }
public AggregateNode GetNode(string name, params string[] path) { if (name.Contains("/") || name.Contains(".")) { var p = name.SmartSplit(false, true, '/','.'); return GetNode(p[0], p.Skip(1).ToArray()); } if (path != null && 0 != path.Length) { var current = GetNode(name); foreach (var s in path) { current = current.GetNode(s); } return current; } if (!Children.ContainsKey(name)) { return Children[name] = new AggregateNode {Parent = this}; } return Children[name]; }
public virtual bool Filter(object o, AggregateNode current, IScope scope) { if (null != FilterFunc) { return FilterFunc(o, current, scope); } return true; }