コード例 #1
0
 public Aggregator()
 {
     Node       = new AggregateNode();
     Routers    = new List <IRouter>();
     Collectors = new List <ICollector>();
     Finalizers = new List <IFinalizer>();
 }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
ファイル: Finalizer.cs プロジェクト: Qorpent/qorpent.sys
 public virtual void Execute(AggregateNode node)
 {
     if (null != ExecuteFunction)
     {
         ExecuteFunction(node);
     }
 }
コード例 #4
0
 public virtual bool Filter(object o, AggregateNode current, IScope scope)
 {
     if (null != FilterFunc)
     {
         return(FilterFunc(o, current, scope));
     }
     return(true);
 }
コード例 #5
0
 protected virtual object InternalGetValue(object src, object currentValue, AggregateNode trg, IScope scope)
 {
     if (null != ValueFunction)
     {
         {
             return(ValueFunction(src, currentValue, trg, scope));
         }
     }
     return(null);
 }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: CountCollector.cs プロジェクト: Qorpent/qorpent.sys
 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();
 }
コード例 #8
0
        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());
        }
コード例 #9
0
        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);
                }
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 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]);
 }
コード例 #12
0
 public virtual bool Filter(object src, AggregateNode trg, IScope scope)
 {
     return(true);
 }
コード例 #13
0
        public virtual object GetValue(object src, object currentValue, AggregateNode trg, IScope scope)
        {
            var result = InternalGetValue(src, currentValue, trg, scope);

            return(result ?? currentValue);
        }
コード例 #14
0
ファイル: AggregateNode.cs プロジェクト: Qorpent/qorpent.sys
 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];
 }
コード例 #15
0
ファイル: Router.cs プロジェクト: Qorpent/qorpent.sys
 public virtual bool Filter(object o, AggregateNode current, IScope scope) {
     if (null != FilterFunc) {
         return FilterFunc(o, current, scope);
     }
     return true;
 }