コード例 #1
0
        protected override void FillObject(FillObjectRequest req)
        {
            XmlNode valuesNode = req.Descriptor.Element.SelectSingleNode(RuleConstants.ValuesNodeName);

            if (valuesNode?.HasChildNodes == true)
            {
                foreach (XmlNode valueNode in valuesNode.ChildNodes)
                {
                    RuleExpression valueElement = SerializerRoot.Container <RuleExpression>()
                                                  .Deserialize(new XmlDescriptor()
                    {
                        Element = valueNode
                    }, req.Parent);

                    (req.Element as Case).ValuesElements.Add(valueElement);
                }
            }

            XmlNode actionNode = req.Descriptor.Element.SelectSingleNode(RuleConstants.ActionNodeName);

            if (actionNode != null)
            {
                (req.Element as Case).ActionElement = SerializerRoot.Container <ExecContainer>()
                                                      .Deserialize(new XmlDescriptor()
                {
                    Element = actionNode
                }, req.Parent);
            }
        }
コード例 #2
0
 public virtual bool ValueExpressionEquals(RuleExpression entity)
 {
     return((entity != null)
            //&& entity is RuleExpression
            && ValueExpression.Equals(entity.ValueExpression));
     //&& this == (RuleExpression<ExpType>)entity;
 }
コード例 #3
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;
            }
        }
コード例 #4
0
ファイル: Case.cs プロジェクト: uzador/TypiconOnline
        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.ExpressionType != valueElement.ExpressionType)
                    {
                        AddBrokenConstraint(CaseBusinessConstraint.ValuesTypeMismatch, ElementName);
                    }
                }
                prevValueElement = valueElement;
            }

            if (ActionElement == null)
            {
                AddBrokenConstraint(CaseBusinessConstraint.ActionsRequired, ElementName);
            }
        }
コード例 #5
0
        protected override bool Operate(RuleExpression exp1, RuleExpression exp2, bool?previousValue)
        {
            int compared = ((RuleComparableExpression)exp1).CompareTo((RuleComparableExpression)exp2);

            bool result = (compared >= 0);

            return((previousValue != null) ? (result && (bool)previousValue) : result);
        }
コード例 #6
0
 public override bool ExpressionTypeEquals(RuleExpression entity)
 {
     if (IsValid)
     {
         return(ValuesElements.First().ExpressionTypeEquals(entity));
     }
     return(false);
 }
コード例 #7
0
 public override bool ValueCalculatedEquals(RuleExpression entity)
 {
     foreach (RuleExpression valueElement in ValuesElements)
     {
         if (valueElement.ValueCalculatedEquals(entity))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #8
0
        protected override void InnerInterpret(IRuleHandler handler)
        {
            RuleExpression exp1 = null;
            RuleExpression exp2 = null;

            bool?expValue = null;

            for (int i = 0; i < ChildElements.Count; i++)
            {
                exp2 = ChildElements[i];
                exp2.Interpret(handler);

                if (exp1 != null)
                {
                    expValue = Operate(exp1, exp2, expValue);
                }

                exp1 = exp2;
            }

            ValueCalculated = expValue;
        }
コード例 #9
0
 protected override bool Operate(RuleExpression exp1, RuleExpression exp2, bool?previousValue)
 {
     return((previousValue != null) ? ((bool)exp1.ValueCalculated && (bool)exp2.ValueCalculated && (bool)previousValue)
         : ((bool)exp1.ValueCalculated && (bool)exp2.ValueCalculated));
 }
コード例 #10
0
        //public virtual bool ValueCalculatedEquals(RuleExpression exp)
        //{
        //    return (exp?.ValueCalculatedEquals(this) == true);
        //}

        /// <summary>
        /// Метод сравнивает типы выражений объектов
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool ExpressionTypeEquals(RuleExpression obj)
        {
            return((obj != null) &&
                   ExpressionType.Equals(obj.ExpressionType));
        }
コード例 #11
0
ファイル: LessEquals.cs プロジェクト: uzador/TypiconOnline
        protected override bool Operate(RuleExpression exp1, RuleExpression exp2, bool?previousValue)
        {
            bool result = (int)exp1.ValueCalculated <= (int)exp2.ValueCalculated;

            return((previousValue != null) ? (result && (bool)previousValue) : result);
        }
コード例 #12
0
 /// <summary>
 /// Метод должен быть реализован во всех наследниках. Используется в методе InnerInterpret
 /// </summary>
 /// <param name="previousValue">предыдущее значение в цепочке</param>
 /// <returns></returns>
 protected abstract bool Operate(RuleExpression exp1, RuleExpression exp2, bool?previousValue);
コード例 #13
0
 public abstract bool ValueCalculatedEquals(RuleExpression entity);
コード例 #14
0
 public abstract bool ExpressionTypeEquals(RuleExpression entity);