Esempio n. 1
0
        /// <inheritdoc/>
        protected override ulong CalculateLongHashCode()
        {
#if DEBUG
            //_gbcLogger.Info($"this = {DebugHelperForRuleInstance.ToString(this)}");
#endif

            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:
                    return(base.CalculateLongHashCode() ^ LongHashCodeWeights.BaseOperatorWeight ^ (ulong)Math.Abs(KindOfOperator.GetHashCode()) ^ Left.GetLongHashCode() ^ Right.GetLongHashCode());

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

            case KindOfLogicalQueryNode.UnaryOperator:
                switch (KindOfOperator)
                {
                case KindOfOperatorOfLogicalQueryNode.Not:
                    return(base.CalculateLongHashCode() ^ LongHashCodeWeights.BaseOperatorWeight ^ (ulong)Math.Abs(KindOfOperator.GetHashCode()) ^ Left.GetLongHashCode());

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

            case KindOfLogicalQueryNode.Concept:
            case KindOfLogicalQueryNode.Entity:
            case KindOfLogicalQueryNode.QuestionVar:
            case KindOfLogicalQueryNode.LogicalVar:
                return(base.CalculateLongHashCode() ^ Name.GetLongHashCode());

            case KindOfLogicalQueryNode.Value:
                return(base.CalculateLongHashCode() ^ Value.GetLongHashCode());

            case KindOfLogicalQueryNode.FuzzyLogicNonNumericSequence:
                return(base.CalculateLongHashCode() ^ FuzzyLogicNonNumericSequenceValue.GetLongHashCode());

            case KindOfLogicalQueryNode.StubParam:
                return(LongHashCodeWeights.StubWeight ^ base.CalculateLongHashCode());

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

            case KindOfLogicalQueryNode.Relation:
            {
                var result = base.CalculateLongHashCode() ^ LongHashCodeWeights.BaseFunctionWeight ^ Name.GetLongHashCode();

                foreach (var param in ParamsList)
                {
                    result ^= LongHashCodeWeights.BaseParamWeight ^ param.GetLongHashCode();
                }

                return(result);
            }

            case KindOfLogicalQueryNode.Group:
                return(base.CalculateLongHashCode() ^ LongHashCodeWeights.GroupWeight ^ Left.GetLongHashCode());

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

            throw new NotImplementedException();
        }
Esempio n. 2
0
        /// <inheritdoc/>
        protected override ulong CalculateLongHashCode()
        {
            var result = base.CalculateLongHashCode() ^ LongHashCodeWeights.BaseOperatorWeight ^ (ulong)Math.Abs(KindOfOperator.GetHashCode());

            return(result);
        }