コード例 #1
0
        protected override void Validate()
        {
            if (ChildElements.Count == 0)
            {
                AddBrokenConstraint(LogicalExpressionBusinessConstraint.ChildrenRequired, ElementName);
            }
            if (ChildElements.Count < 2)
            {
                AddBrokenConstraint(LogicalExpressionBusinessConstraint.NotEnoughChildren, ElementName);
            }

            RuleExpression exp1 = null;
            RuleExpression exp2 = null;

            for (int i = 0; i < ChildElements.Count; i++)
            {
                exp2 = ChildElements[i];
                if (exp2 == null)
                {
                    AddBrokenConstraint(LogicalExpressionBusinessConstraint.InvalidChild, ElementName);
                }
                else
                {
                    //Проверяем, элемент с каким выходным типом значения
                    //сравниваем ExpressionType элементов
                    if (exp1?.ExpressionTypeEquals(exp2) == false)
                    {
                        AddBrokenConstraint(LogicalExpressionBusinessConstraint.TypeMismatch, ElementName);
                    }
                }
                exp1 = exp2;
            }
        }
コード例 #2
0
        protected override void Validate()
        {
            if (ValuesElements.Count == 0)
            {
                AddBrokenConstraint(CaseBusinessConstraint.ValuesRequired, ElementName);
            }

            RuleExpression prevValueElement = null;

            foreach (RuleExpression valueElement in ValuesElements)
            {
                //проверяем, одного ли типа элементы
                if (prevValueElement != null)
                {
                    if (!prevValueElement.ExpressionTypeEquals(valueElement))
                    {
                        AddBrokenConstraint(CaseBusinessConstraint.ValuesTypeMismatch, ElementName);
                    }
                }
                prevValueElement = valueElement;
            }

            if (ActionElement == null)
            {
                AddBrokenConstraint(CaseBusinessConstraint.ActionsRequired, ElementName);
            }
        }