Exemplo n.º 1
0
        public ulong GetLongConditionalHashCode()
        {
            Name.CheckDirty();

            if (!TypesList.IsNullOrEmpty())
            {
                foreach (var item in TypesList)
                {
                    item.CheckDirty();
                }
            }

            DefaultValue?.CheckDirty();

            var result = Name.GetLongConditionalHashCode();

            if (!TypesList.IsNullOrEmpty())
            {
                foreach (var item in TypesList)
                {
                    result ^= item.GetLongConditionalHashCode();
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        protected override ulong CalculateLongHashCode()
        {
            Name.CheckDirty();

            var result = base.CalculateLongHashCode() ^ Name.GetLongHashCode();

            if (Range != null)
            {
                Range.CheckDirty();

                result ^= Range.GetLongHashCode();
            }

            if (Constraint != null)
            {
                Constraint.CheckDirty();
            }

            if (!Values.IsNullOrEmpty())
            {
                foreach (var value in Values)
                {
                    value.CheckDirty();

                    result ^= value.GetLongHashCode();
                }
            }

            if (!Operators.IsNullOrEmpty())
            {
                foreach (var op in Operators)
                {
                    op.CheckDirty();

                    result ^= op.GetLongHashCode();
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        //public bool HasQuestionVars
        //{
        //    get
        //    {
        //        if(IsQuestion)
        //        {
        //            return true;
        //        }

        //        if(Left != null && Left.HasQuestionVars)
        //        {
        //            return true;
        //        }

        //        if(Right != null && Right.HasQuestionVars)
        //        {
        //            return true;
        //        }

        //        if (ParamsList != null && ParamsList.Any(p => p.HasQuestionVars))
        //        {
        //            return true;
        //        }

        //        return false;
        //    }
        //}

        public void PrepareDirty(ContextOfConvertingExpressionNode contextOfConvertingExpressionNode, RuleInstance ruleInstance, BaseRulePart rulePart)
        {
#if DEBUG
            //_gbcLogger.Info($"this = {this}");
            //_gbcLogger.Info($"contextOfConvertingExpressionNode = {contextOfConvertingExpressionNode}");
#endif

            RuleInstance = ruleInstance;
            RulePart     = rulePart;

            switch (Kind)
            {
            case KindOfLogicalQueryNode.BinaryOperator:
                switch (KindOfOperator)
                {
                case KindOfOperatorOfLogicalQueryNode.And:
                case KindOfOperatorOfLogicalQueryNode.Or:
                case KindOfOperatorOfLogicalQueryNode.Is:
                case KindOfOperatorOfLogicalQueryNode.IsNot:
                case KindOfOperatorOfLogicalQueryNode.More:
                case KindOfOperatorOfLogicalQueryNode.MoreOrEqual:
                case KindOfOperatorOfLogicalQueryNode.Less:
                case KindOfOperatorOfLogicalQueryNode.LessOrEqual:
                    Left.PrepareDirty(contextOfConvertingExpressionNode, ruleInstance, rulePart);
                    Right.PrepareDirty(contextOfConvertingExpressionNode, ruleInstance, rulePart);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(KindOfOperator), KindOfOperator, null);
                }
                break;

            case KindOfLogicalQueryNode.UnaryOperator:
                switch (KindOfOperator)
                {
                case KindOfOperatorOfLogicalQueryNode.Not:
                    Left.PrepareDirty(contextOfConvertingExpressionNode, ruleInstance, rulePart);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(KindOfOperator), KindOfOperator, null);
                }
                break;

            case KindOfLogicalQueryNode.Concept:
            case KindOfLogicalQueryNode.Entity:
            case KindOfLogicalQueryNode.QuestionVar:
                Name.CheckDirty();
                break;

            case KindOfLogicalQueryNode.LogicalVar:
                contextOfConvertingExpressionNode.HasVars = true;
                Name.CheckDirty();
                break;

            case KindOfLogicalQueryNode.Value:
            case KindOfLogicalQueryNode.StubParam:
            case KindOfLogicalQueryNode.EntityCondition:
            case KindOfLogicalQueryNode.EntityRef:
                break;

            case KindOfLogicalQueryNode.FuzzyLogicNonNumericSequence:
                FuzzyLogicNonNumericSequenceValue.CheckDirty();
                break;

            case KindOfLogicalQueryNode.Relation:
                Name.CheckDirty();
                if (Name.KindOfName == KindOfName.LogicalVar)
                {
                    IsQuestion = true;
                }
                FillRelationParams(ParamsList, contextOfConvertingExpressionNode);
                break;

            case KindOfLogicalQueryNode.Group:
                Left.PrepareDirty(contextOfConvertingExpressionNode, ruleInstance, rulePart);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(Kind), Kind, null);
            }

#if DEBUG
            //_gbcLogger.Info($"contextOfConvertingExpressionNode (after) = {contextOfConvertingExpressionNode}");
#endif
        }