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); }
public CommutativePredicate(IEnumerable <SemanticContext> contexts) { if (contexts == null) { throw new ArgumentNullException("contexts"); } foreach (var context in contexts) { CommutativePredicate commutative = context as CommutativePredicate; if (commutative != null && commutative.GetType() == this.GetType()) { _operands.UnionWith(commutative._operands); } else if (context != null) { _operands.Add(context); } } _hashcode = CalculateHashCode(); }