this.function = function;
this.result = null;
}
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is Aggregation))
+ return false;
+
+ Aggregation other = (Aggregation) obj;
+ if (!other.function.Equals( function))
+ return false;
+
+ if (!other.column.Equals (column))
+ return false;
+
+ if (other.rows.Length != rows.Length)
+ return false;
+
+ for (int i=0; i < rows.Length; i++)
+ if (other.rows [i] != rows [i])
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = base.GetHashCode ();
+ hashCode ^= function.GetHashCode ();
+ hashCode ^= column.GetHashCode ();
+ for (int i=0; i < rows.Length; i++)
+ hashCode ^= rows [i].GetHashCode ();
+
+ return hashCode;
+ }
public override object Eval (DataRow row)
{
+2005-09-19 Boris Kirzner <borisk@mainsoft.com>
+ * ColumnReference.cs, Expressions.cs, Like.cs, Aggregation.cs, Literal.cs,
+ StringFunctions.cs, In.cs, Functions.cs : implemented Equals()
+ and GetHashCode() methods for all Mono.Data.SqlExpressions classes,enabling
+ comparison of the filter expressions.
+
2005-08-02 Sureshkumar T <tsureshkumar@novell.com>
* Tokenizer.cs: ReadString (): added an overload where the
this.columnName = columnName;
}
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is ColumnReference))
+ return false;
+
+ ColumnReference other = (ColumnReference) obj;
+ if (other.refTable != refTable)
+ return false;
+
+ if (other.columnName != columnName)
+ return false;
+
+ if (other.relationName != relationName)
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = base.GetHashCode ();
+ hashCode ^= refTable.GetHashCode ();
+ hashCode ^= columnName.GetHashCode ();
+ hashCode ^= relationName.GetHashCode ();
+ return hashCode;
+ }
+
public ReferencedTable ReferencedTable {
get { return refTable; }
}
{
return (bool) Eval (row);
}
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null || !(obj is BaseExpression))
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return 0;
+ }
}
// abstract base classes
internal abstract class UnaryExpression : BaseExpression {
protected IExpression expr;
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is UnaryExpression))
+ return false;
+
+ UnaryExpression other = (UnaryExpression) obj;
+ if (!other.expr.Equals (expr))
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode () ^ expr.GetHashCode ();
+ }
public UnaryExpression (IExpression e)
{
internal abstract class BinaryExpression : BaseExpression {
protected IExpression expr1, expr2;
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is BinaryExpression))
+ return false;
+
+ BinaryExpression other = (BinaryExpression) obj;
+ if (!other.expr1.Equals (expr1) || !other.expr2.Equals (expr2))
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = base.GetHashCode ();
+ hashCode ^= expr1.GetHashCode ();
+ hashCode ^= expr2.GetHashCode ();
+ return hashCode;
+ }
protected BinaryExpression (IExpression e1, IExpression e2)
{
internal abstract class BinaryOpExpression : BinaryExpression {
protected Operation op;
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is BinaryOpExpression))
+ return false;
+
+ BinaryOpExpression other = (BinaryOpExpression) obj;
+ if (other.op != op)
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode () ^ op.GetHashCode ();
+ }
protected BinaryOpExpression (Operation op, IExpression e1, IExpression e2) : base (e1, e2)
{
this.trueExpr = trueExpr;
this.falseExpr = falseExpr;
}
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is IifFunction))
+ return false;
+
+ IifFunction other = (IifFunction) obj;
+ if (!other.falseExpr.Equals (falseExpr))
+ return false;
+
+ if (!other.trueExpr.Equals (trueExpr))
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = base.GetHashCode ();
+ hashCode ^= falseExpr.GetHashCode ();
+ hashCode ^= trueExpr.GetHashCode ();
+ return hashCode;
+ }
override public object Eval (DataRow row)
{
{
this.defaultExpr = defaultExpr;
}
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is UnaryExpression))
+ return false;
+
+ IsNullFunction other = (IsNullFunction) obj;
+ if (!other.defaultExpr.Equals (defaultExpr))
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return defaultExpr.GetHashCode () ^ base.GetHashCode ();
+ }
override public object Eval (DataRow row)
{
throw new EvaluateException (String.Format ("Invalid type name '{0}'.", targetType));
}
}
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is ConvertFunction))
+ return false;
+
+ ConvertFunction other = (ConvertFunction) obj;
+ if (other.targetType != targetType)
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return targetType.GetHashCode () ^ base.GetHashCode ();
+ }
override public object Eval (DataRow row)
{
{
this.set = set;
}
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is In))
+ return false;
+
+ In other = (In) obj;
+ if (other.set.Count != set.Count)
+ return false;
+
+ IEnumerator enumerator = set.GetEnumerator ();
+ IEnumerator oenumerator = other.set.GetEnumerator ();
+
+ do {
+ if (!oenumerator.Current.Equals (enumerator.Current))
+ return false;
+ }
+ while (enumerator.MoveNext () || oenumerator.MoveNext ());
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = base.GetHashCode ();
+ IEnumerator enumerator = set.GetEnumerator ();
+
+ do {
+ hashCode ^= enumerator.Current.GetHashCode ();
+ }
+ while (enumerator.MoveNext ());
+ return hashCode;
+ }
override public object Eval (DataRow row)
{
this.pattern = pattern;
}
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is Like))
+ return false;
+
+ Like other = (Like) obj;
+ if (other.pattern != pattern)
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return pattern.GetHashCode () ^ base.GetHashCode ();
+ }
+
override public object Eval (DataRow row)
{
object o = expr.Eval (row);
{
this.val = val;
}
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is Literal))
+ return false;
+
+ Literal other = (Literal) obj;
+ if (other.val != null) {
+ if (!other.val.Equals (val))
+ return false;
+ }
+ else if (val != null)
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return val.GetHashCode () ^ base.GetHashCode ();
+ }
public override object Eval (DataRow row)
{
this.start = start;
this.len = len;
}
+
+ public override bool Equals(object obj)
+ {
+ if (!base.Equals (obj))
+ return false;
+
+ if (!(obj is SubstringFunction))
+ return false;
+
+ SubstringFunction other = (SubstringFunction) obj;
+ if (other.start != start)
+ return false;
+
+ if (other.len != len)
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = base.GetHashCode ();
+ hashCode ^= start.GetHashCode ();
+ hashCode ^= len.GetHashCode ();
+ return hashCode;
+ }
override public object Eval (DataRow row)
{