예제 #1
0
        public override void Parse(object data, ILogicStack stack)
        {
            ILogicResult    sum = new LogicResult(0);
            ILogicOperation op  = new LogicOperation("Add", true);

            foreach (ILogicNode node in this)
            {
                node.Parse(data, stack);
                KeyValuePair <ILogicOperation, ILogicResult> item = stack.Pop();
                sum = sum.Add(item.Value);
                if (item.Key != null)
                {
                    op.Add(item.Key);
                }
            }
            op.Result = sum.ToString();
            stack.Push(new KeyValuePair <ILogicOperation, ILogicResult>(op, sum));
        }
예제 #2
0
        public override void Parse(object data, ILogicStack stack)
        {
            ILogicOperation op = new LogicOperation("Min");
            ILogicResult    r1 = new LogicResult(LogicResult.MaxValue);

            foreach (ILogicNode node in this)
            {
                node.Parse(data, stack);
                KeyValuePair <ILogicOperation, ILogicResult> r = stack.Pop();
                if (r.Value.CompareTo(r1) < 0)
                {
                    // Set the minimum
                    r1.Value = r.Value.Value;
                }
                op.Add(r.Key);
            }
            op.Result = r1.Value.ToString();
            stack.Push(new KeyValuePair <ILogicOperation, ILogicResult>(op, r1));
        }