Esempio n. 1
0
        protected void AppendBaseRulePart(BaseRulePart source, Dictionary <object, object> context)
        {
            IsActive        = source.IsActive;
            Parent          = source.Parent.Clone(context);
            Expression      = source.Expression.Clone(context);
            HasQuestionVars = source.HasQuestionVars;
            HasVars         = source.HasVars;
            RelationsDict   = source.RelationsDict.ToDictionary(p => p.Key, p => (IList <LogicalQueryNode>)(p.Value.Select(x => x.Clone(context)).ToList()));

            AppendAnnotations(source, context);
        }
Esempio n. 2
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
        }