コード例 #1
0
        public string Visit(IfElement ifElement)
        {
            var isTopIf = false;

            if (_conditionals == null)
            {
                _conditionals = new List <string>();
                isTopIf       = true;
            }

            var trueValue = ifElement.TrueValue.Accept(this);

            _conditionals.Add(trueValue);

            var falseValue = ifElement.FalseValue.Accept(this);

            _conditionals.Add(falseValue);

            if (isTopIf)
            {
                var result = JoinAlternatives(_conditionals);
                _conditionals = null;
                return(result);
            }

            return(null);
        }
コード例 #2
0
        private ConditionResult assertCondition(IfElement condition)
        {
            ConditionResult _assertResult = null;

            string valueOF       = condition.getAttribute(AttributeConstants.VALUE_OF).getValue().ToString();
            object expectedValue = condition.getAttribute(AttributeConstants.VALUE).getValue();
            string conditionType = condition.getAttribute(AttributeConstants.CONDITION).getValue().ToString();

            object valueToCheck = this._AttributeSelector.valueOf(valueOF);

            if (valueToCheck == null)
            {
                throw new Exception("Could not assert [null] value-of.");
            }

            try
            {
                ConditionType _condition = EnumUtil.Parse <ConditionType>(conditionType);
                _assertResult = new ConditionResult(
                    AssertionUtil.AssertCondition(_condition, expectedValue, valueToCheck),
                    condition.DoNodes,
                    condition.ElseNodes);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(_assertResult);
        }
コード例 #3
0
        public static IElement CreateControlFlowElement(XmlNode node, ControlFlowType type)
        {
            IElement _return = null;

            switch (type)
            {
            case ControlFlowType.If:
                _return = new IfElement(node, CreateElements(node.SelectNodes(DO_NODE)), CreateElements(node.SelectNodes(ELSE_NODE)));
                break;

            case ControlFlowType.ForEach:
                _return = new ForEachElement(node, CreateElements(node.SelectNodes(DO_NODE)));
                break;

            case ControlFlowType.Repeat:
                _return = new RepeatElement(node, CreateElements(node.SelectNodes(DO_NODE)));
                break;

            case ControlFlowType.While:
                break;

            case ControlFlowType.Switch:
                break;

            default:
                break;
            }
            return(_return);
        }
コード例 #4
0
 public IfElement CheckElement(IfElement ifElement)
 {
     foreach (var E in ElementCollection)
     {
         if (E.IfDimension == ifElement.IfDimension)
         {
             return(E);
         }
     }
     return(null);
 }
コード例 #5
0
 public void AddToCollection(IEnumerable <IfElement> ifElements)
 {
     foreach (var item in ifElements)
     {
         int       index;
         IfElement E = CheckElement(item);
         if (E != null)
         {
             index = ElementCollection.IndexOf(E);
             DataRow DR = BOQTable.Rows[index];
             DR.SetField <int>("Number", DR.Field <int>("Number") + 1);
             NumberOfElements[index]++;
         }
         else
         {
             BOQTable.Rows.Add(item.ToString(), 1);
             ElementCollection.Add(item);
             NumberOfElements.Add(1);
         }
     }
 }