Пример #1
0
            public override bool Equals(SemanticContext other)
            {
                if (object.ReferenceEquals(this, other))
                {
                    return(true);
                }

                CommutativePredicate commutative = other as CommutativePredicate;

                if (commutative != null && other.GetType() == this.GetType())
                {
                    ICollection <SemanticContext> otherOperands = commutative.Operands;
                    return(_operands.SetEquals(otherOperands));
                }

                NOT not = other as NOT;

                if (not != null)
                {
                    commutative = not.ctx as CommutativePredicate;
                    if (commutative != null && commutative.GetType() != this.GetType())
                    {
                        return(_operands.SetEquals(commutative.Operands.Select(i => Not(i))));
                    }
                }

                return(false);
            }
Пример #2
0
            protected CommutativePredicate(SemanticContext a, SemanticContext b)
            {
                if (a == null)
                {
                    throw new ArgumentNullException("a");
                }
                if (b == null)
                {
                    throw new ArgumentNullException("b");
                }

                if (a.GetType() == this.GetType())
                {
                    _operands.UnionWith(((CommutativePredicate)a).Operands);
                }
                else
                {
                    _operands.Add(a);
                }

                if (b.GetType() == this.GetType())
                {
                    _operands.UnionWith(((CommutativePredicate)b).Operands);
                }
                else
                {
                    _operands.Add(b);
                }

                _hashcode = CalculateHashCode();
            }